math.rank

math.rank(
   arg1 as (String | Number | Boolean | null | Array | Object)[],
   arg2 as xs.anyAtomicType,
   [options as String[]]
) as Number?

Summary

Returns the rank of a value in a data set. Ranks are skipped in the event of ties. If the given value is not equal to any item in the sequence, the function returns the empty sequence. The function can be used on numeric values, xs:yearMonthDuration, xs:dayTimeDuration, xs:string, xs:anyURI, xs:date, xs:dateTime, xs:time, and cts:point.

Parameters
arg1 The sequence of values.
arg2 The value to be "ranked".
options Options. The default is ().

Options include:

"ascending"(default)
Rank the value as if the sequence was sorted in ascending order.
"descending"
Rank the value as if the sequence was sorted in descending order.
"collation=URI"
Applies only when $arg is of the xs:string type. If no specified, the default collation is used.
"coordinate-system=name"
Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used.

Example

  math.rank([1, 7, 5, 5, 10, 9],9)

  => 5
Powered by MarkLogic Server | Terms of Use | Privacy Policy