Loading TOC...

MarkLogic Server 11.0 Product Documentation
math:rank

math:rank(
   $arg1 as xs:anyAtomicType*,
   $arg2 as xs:anyAtomicType,
   [$options as xs:string*]
) as xs:integer?

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

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.