Extracted from Pike v7.4 release 117 at 2004-11-02.
pike.ida.liu.se
[Top]
predef::

Method sort()


Method sort

array sort(array(mixed) index, array(mixed) ... data)

Description

Sort arrays destructively.

This function sorts the array index destructively. That means that the array itself is changed and returned, no copy is created.

If extra arguments are given, they are supposed to be arrays of the same size as index . Each of these arrays will be modified in the same way as index . I.e. if index 3 is moved to position 0 in index index 3 will be moved to position 0 in all the other arrays as well.

sort() can sort strings, integers and floats in ascending order. Arrays will be sorted first on the first element of each array. Objects will be sorted in ascending order according to `<() , `>() and `==() .

Returns

The first argument will be returned.

Note

The sorting algorithm used is not stable, ie elements that are equal may get reordered.

See also

reverse()