function

sort . array . sncode

VERSIONlatest Sort an array.

SORT

NAME

sort - Sort an array.

SYNOPSIS

sort([sort:integer,fname:string] array)

DESCRIPTION

This function sort an array. By default sort will look at the first element to guest the sorting type.

You can specify the sort type to be 0 for integer, 1 for string, 2 for your sort function and 3 for float.

A sort function receive to element and you must compare them.

EXAMPLES

sort([1.5,5,2,98,32,7,2,5]);
return [1.5,2,2,5,5,7,32,98]

function f(a,b)
            return b - a;
endf
sort(sort:2,fname:"f",[1,5,2,98,32,7,2,5]);        
return [98,32,7,5,5,2,2,1]

sort([1,5,2,98,32,7,2,5]); }}.
return [1,2,2,5,5,7,32,98]

sort(sort:0,[1,5,2,98,32,7,2,5]); }}
return [1,2,2,5,5,7,32,98]

sort(sort:1,['gt','ab', 'ba', 'cd']);
return ["ab","ba","cd","gt"]
  

AUTHOR

Written by Pierre Laplante, <laplante@sednove.com>