sort


Description:

[ Version ( since = "2.4" ) ]
public void sort (CompareDataFunc<G> compare_func)

Sorts this using compare_func.

Example: Sort all items:

public static int main () {
Queue<string> queue = new Queue<string> ();
queue.push_tail ("2");
queue.push_tail ("1");
queue.push_tail ("3");

bool asc = true;
queue.sort ((a, b) => {
return (asc)? strcmp (a, b) : strcmp (b, a);
});

// Output: ``1 2 3 ``
string item = null;
while ((item = queue.pop_head ()) != null) {
print ("%s ", item);
}
print ("\n");

return 0;
}

valac --pkg glib-2.0 GLib.Queue.sort.vala

Parameters:

this

a Queue

compare_func

the CompareDataFunc used to sort this . This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.

user_data

user data passed to compare_func