sort_array.html

final_realms_fluffos_v1/lib/doc/man/html/efuns/arrays/sort_array.html · 1.3 KB

From the archive final_realms_fluffos_v1.zip

Download the archive   « Back to the archive contents

<HEAD> <TITLE> sort_array - sort an array </TITLE> </HEAD> <BODY BACKGROUND=http://www.imaginary.com/~beek/gifs/bg.jpg TEXT=#000000 ALINK=#FFFF00 VLINK=#550000 LINK=#000099> <center> <H1> sort_array - sort an array </H1> </center>
<p>
<b> array sort_array( array arr, string fun, object ob ); </b>
<p>
<b> array sort_array( array arr, function f ); </b>
<p>
<b> array sort_array( array arr, int direction ); </b>
<p>
The (ob, fun) syntax behaves the same as if (: call_other, ob, fun :)
was passed as f.
<p>
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.
<p>
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.
<p>
See also:
<A HREF=../strings/strcmp.html>  strcmp </A>

Site Stats

Snippets: 1791
Codebases: 571