<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/math.rank.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>math.rank</api:function-name><api:suggest>math.rank</api:suggest><api:suggest>math</api:suggest><api:suggest>rank</api:suggest><api:function-link mode="xquery" fullname="math:rank">/apidoc/8.0/math:rank.xml</api:function-link><api:function mode="javascript" name="rank" type="builtin" lib="math" category="MathBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="math" namespace="http://marklogic.com/xdmp/math" fullname="math.rank"><api: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, <code xmlns="http://www.w3.org/1999/xhtml">xs:yearMonthDuration</code>, <code xmlns="http://www.w3.org/1999/xhtml">xs:dayTimeDuration</code>, 
  <code xmlns="http://www.w3.org/1999/xhtml">xs:string</code>, <code xmlns="http://www.w3.org/1999/xhtml">xs:anyURI</code>,
  <code xmlns="http://www.w3.org/1999/xhtml">xs:date</code>, <code xmlns="http://www.w3.org/1999/xhtml">xs:dateTime</code>, <code xmlns="http://www.w3.org/1999/xhtml">xs:time</code>,
  and <code xmlns="http://www.w3.org/1999/xhtml">cts:point</code>.
</api:summary><api:params><api:param name="arg" type="xs:anyAtomicType*"><api:param-description>
  The sequence of values.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>(String | Number | Boolean | null)[]</api:param-type></api:param><api:param name="arg" type="xs:anyAtomicType"><api:param-description>
  The value to be "ranked".
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>xs.anyAtomicType</api:param-type></api:param><api:param name="options" type="xs:string*" optional="true"><api:param-description>
    Options.  The default is ().
    <p xmlns="http://www.w3.org/1999/xhtml">
      Options include:</p>
      <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
        <dt>"ascending"(default)</dt>
        <dd>Rank the value as if the sequence was sorted in ascending order.
        </dd>
        <dt>"descending"</dt>
        <dd>Rank the value as if the sequence was sorted in descending order.
        </dd>
        <dt>"collation=<em>URI</em>"</dt>
        <dd>Applies only when $arg is of the xs:string type. If no specified,
        the default collation is used.</dd>
        <dt>"coordinate-system=<em>name</em>"</dt>
        <dd>Applies only when $arg is of the cts:point type. If no specified,
        the default coordinate system is used.</dd>
      </dl></blockquote>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>Number?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  math.rank([1, 7, 5, 5, 10, 9],9)

  =&gt; 5
</pre></api:example></api:function></api:function-page>