|Returns the {{Code|$k}} items in {{Code|$seq}} that are greatest when sorted by the result of {{Code|$f}} applied to the item. The function is a much more efficient implementation of the following scheme:
<pre class="brush:xquery">
( for $x in $seq order by $sort-key($x) descending return $x
)[position() <= $k]
</pre>