Sort —
void Sort( | mode, | |
| compareFunc, | ||
alg); |
| int | mode; |
| string | compareFunc; |
| int | alg; |
Sorts elements in array
Parameters
Determines the order of the array after the sort. Possible values can be constant.array.asc and constant.array.desc (default is constant.array.asc)
If this parameter is "" or not specified, the sort is performed executing a comparison operator for the class type of the array elements. Otherwise, if this parameter is specified, the function with the given name will be called to compare elements of array. The prototype of the function (callback) must be:
function boolean CompareFunc(array *theArray, int index1, int index2, int mode);
The array, two indexes and the mode (asc or desc) will be passed. The function must return:true if elements must be swapped, false if not.
Determines the sort algorithm. Possible values can be constant.array.bubble and constant.array.shell. If it is not specified, shell is used if elements are more than 20, bubble otherwise.