SortListUsingHandler
Type
statement
Summary
Sorts Target using Handler as a comparison function.
Syntax
sort <Target> using handler <Handler>
Description
SortListUsingHandler sorts a list by comparing the elements of a list according to the comparison implemented by the Handler argument.
note
Supplying an inconsistent comparison operator to SortListUsingHandler causes undefined behavior.
Parameters
| Name | Type | Description | 
|---|---|---|
| Target | An expression that evaluates to a list. | |
| Handler | A handler of type SortCompare | 
Examples
variable sKeyIndex as Number
private handler CompareListsByElement(in pLeft as any, in pRight as any) returns Integer
   variable tLeft as Number
   variable tRight as Number
   put pLeft[sKeyIndex] into tLeft
   put pRight[sKeyIndex] into tRight
   if tLeft > tRight then
      return 1
   else if tLeft < tRight then
      return -1
   else
      return 0
   end if
end handler
-- Sort lists according to value at specified index of each list
public handler TestSortListOfLists(in pList as List, in pKeyIndex as Number) returns List
   put pKeyIndex into sKeyIndex
   sort pList using handler CompareListsByElement
   return pList
end handler