Sorts the array, using compare_func which should be a qsort()-style
comparison function (returns less than zero for first arg is less
than second arg, zero for equal, greater than zero if irst arg is
greater than second arg).
Note that the comparison function for PtrArray.sort doesn't
take the pointers from the array as arguments, it takes pointers to
the pointers in the array. Here is a full example of usage:
typedefstruct
{
gchar *name;
gint size;
} FileListEntry;
static gint
sort_filelist (gconstpointer a, gconstpointer b)
{
const FileListEntry *entry1 = *((FileListEntry **) a);
const FileListEntry *entry2 = *((FileListEntry **) b);
return g_ascii_strcasecmp (entry1->name, entry2->name);
}
…
g_autoptr (GPtrArray) file_list = NULL;
// initialize file_list array and load with many FileListEntry entries
...
// now sort it with
g_ptr_array_sort (file_list, sort_filelist);
This is guaranteed to be a stable sort since version 2.32.
Sorts the array, using compare_func which should be a qsort()-style comparison function (returns less than zero for first arg is less than second arg, zero for equal, greater than zero if irst arg is greater than second arg).
Note that the comparison function for PtrArray.sort doesn't take the pointers from the array as arguments, it takes pointers to the pointers in the array. Here is a full example of usage:
This is guaranteed to be a stable sort since version 2.32.