sort
Description:
Sorts this using cmp_func
.
cmp_func
is passed two items of this 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.
Example: Sort all items:
public static int main (string[] args) {
Sequence<string> seq = new Sequence<string> ();
seq.append ("1. Lorem");
seq.append ("4. amet");
seq.append ("2. ipsum");
seq.append ("3. sit");
bool asc = true;
seq.sort ((a, b) => {
return (asc)? strcmp (a, b) : strcmp (b, a);
});
// Output:
// ``1. Lorem``
// ``2. ipsum``
// ``3. sit``
// ``4. amet``
seq.foreach ((item) => {
print ("%s\n", item);
});
return 0;
}
valac --pkg glib-2.0 GLib.Sequence.sort.vala
Parameters:
this |
a Sequence |
cmp_func |
the function used to sort the sequence |
cmp_data |
user data passed to |