|position||An integer indicating the element in the sorted set to return.|
|set||The set of values.|
|DESCEND||Optional. Indicates descending order sort.|
|Return:||RANK returns a single value.|
The RANK function sorts the set in ascending (or descending, if DESCEND is present) order, then returns the ordinal position (its index value) of the unsorted set's position element after the set has been sorted. This is the opposite of RANKED.
Ranking := RANK(1,[20,30,10,40]); // returns 2 - 1st element (20) in unsorted set is // 2nd element after sorting to [10,20,30,40] Ranking := RANK(1,[20,30,10,40],DESCEND); // returns 3 - 1st element (20) in unsorted set is // 3rd element after sorting to [40,30,20,10]