Lasso Soft Inc. > Home

[Array->Sort]

[Array->Sort] reorders the elements of the array in alphabetical or numerical order. Accepts a single boolean parameter. Sorts in ascending order by default or if the parameter is True and in descending order if the parameter is False.

Note: Only string, integer, or decimal values should be sorted. If an array contains arrays or maps then the results of sorting the array are undetermined. Pairs will be sorted by their first element (which should be either a string, integer, or decimal value).

  • Syntax
  • Parameters
[Array->(Sort: Sort Order)]
Required Parameters
Array The array which is to be sorted.
Optional Parameters
Sort Order If True, specifies the array should be sorted in ascending numeric or alphabetic order. If False, specifies the array should be sorted in descending order.
Examples

To sort the elements in an array:

Use the [Array->Sort] tag. The following example sorts the items in an array of the days of the week and outputs the sorted array.

<?LassoScript
  Variable: 'DaysOfWeek'=(Array: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
  Output: $DaysOfWeek->(Sort: True);
  Output: $DaysOfWeek;
?>
Result:
(Array: (Fri), (Mon), (Thu), (Tue), (Sat), (Sun), (Wed))
Tag Link [Array->Sort] Category Array
Type Member Data Source Any
Support Preferred Version 5.0
Output Type None Security None
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft