Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Siebel eScript Commands > Array Objects > Array sort() MethodThe sort() method sorts the elements of an array into the order specified by the compareFunction. SyntaxarrayName.sort([compareFunction]) ReturnsarrayName with its elements sorted into the order specified. UsageIf no compareFunction is supplied, then elements are converted to strings before sorting. When numbers are sorted into ASCII order, they are compared left-to-right, so that, for example, 32 comes before 4. This may not be the result you want. However, the compareFunction allows you to specify a different way to sort the array elements. The name of the function you want to use to compare values is passed as the only parameter to sort(). If a compare function is supplied, the array elements are sorted according to the return value of the compare function. ExampleThe following example demonstrates the use of the sort() method with and without a compare function. It first displays the results of a sort without the function and then uses a user-defined function,
|
Siebel eScript Language Reference |