
MarkLogic 9 Product Documentation
math:rankmath: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
    Copyright © 2025 MarkLogic Corporation. MARKLOGIC is a
    registered trademark of MarkLogic Corporation.