Search code examples
glib

Using g_array_sort function


I need to use the function g_array_sort(GArray *array, GCompareFunc *func) but I do not understand the second parameter.

Please show me how it should be called and if possible please attach a sample example....


Solution

  • This is an open source library, so you could take a look at the code of g_array_sort() itself. Just type in g_array_sort into Google's code search and you'll get the code.

    There you can see that this function actually calls libc's qsort(3) and passes the function you are interested in to qsort unchanged.

    Now, Linux's qsort man page has a good example of qsort use.