sort_with_data
Description:
[ CCode ( cname = "vala_g_ptr_array_sort_with_data" ) ]
public void sort_with_data (CompareDataFunc<G> compare_func)
public void sort_with_data (CompareDataFunc<G> compare_func)
Sorts the array, using compare_func
Example: Sort all items (with data):
public static int main (string[] args) {
GenericArray<string> array = new GenericArray<string> ();
array.add ("second entry");
array.add ("third entry");
array.add ("first entry");
bool asc = true;
array.sort_with_data ((a, b) => {
return (asc)? strcmp (a, b) : strcmp (b, a);
});
// Output:
// ``first entry``
// ``second entry``
// ``third entry``
array.foreach ((str) => {
print ("%s\n", str);
});
return 0;
}
valac --pkg glib-2.0 GLib.GenericArray.sort_with_data.vala
Parameters:
compare_func |
a comparison function, qsort-style, with a target |