sort_array
skylib_fluffos_v3/mudlib/doc/driver/efuns/arrays/sort_array · 1.3 KB
From the archive skylib_fluffos_v3.zip
Download the archive « Back to the archive contents
.\"sort an array .DT sort_array $MUDNAME$ driver help sort_array .SH Name .SI 5 sort_array() - sort an array .EI .SH Synopsis .SI 5 mixed *sort_array( mixed *arr, string fun, object ob, ... ); mixed *sort_array( mixed *arr, function f, ... ); mixed *sort_array( mixed *arr, int direction ); .EI .SH Description .SP 5 5 The (ob, fun) syntax behaves the same as if (: call_other, ob, fun :) was passed as f. In the first two forms, the returned array is sorted with respect to the comparison function given. The function takes two elements as arguments, and returns -1 if if first argument is less than the second, 0 if they are the same, or 1 if the first argument is greater than the second. Any additional arguments are passed to the comparison function as the third and following arguments. The third form returns an array with the same elements as 'arr', but quicksorted using built-in sort routines. A 'direction' of 1 or 0 will quicksort in ascending order, while a 'direction' of -1 will quicksort in descending order. A limitation of the built-in sort routines is that the array must be homogeneous, composed entirely of a single type, where that type is string, int, or float. Arrays of arrays are sorted by sorting based on the first element, making database sorts possible. .EP .SH See also .SI 5 filter(), map(), strcmp() .EI