Reputation: 195
I'm trying to use the simple mapping operator (!) as below
(1,7,2,4,5)!(.)
The above would return 1,7,2,4,5 as a sequence.But I need the values to be sorted in ascending order.
Is it possible to use order by with this mapping operator?If so,please share an example to do the same.
Thanks!
Upvotes: 1
Views: 450
Reputation: 66781
Unfortunately, fn:sort()
is not currently available in MarkLogic.
The easiest way to achieve what you want is probably a FLWOR, as Martin Honnen suggested.
for $i in (1,7,2,4,5)
order by $i
return $i
The functx libraries are installed and available in MarkLogic, so you could leverage functx:sort()
:
xquery version "1.0-ml";
import module namespace functx = "http://www.functx.com"
at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
(1,7,2,4,5) => functx:sort()
Or you could create your own custom function wrapping that FLWOR with order by
.
Upvotes: 1