Re: improvements to fn:sort functions

On Sat, Jan 16, 2021 at 2:04 PM Christian Grün <cg@basex.org> wrote:

> > For correctness sake, I guess you meant,
> > sort($data, (), function($key) { 0 - $key })
>
> Both are possible; see [1] for more details on unary expressions.
>

Thanks, for the clarification.

>
> > Wouldn't this be inefficient, as compared to having a native
> "descending" argument to the fn:sort function?
>
> I can’t talk for all implementations, but it’s easily optimizable (in
> BaseX, you shouldn’t note the difference)
>

From simply a theoretical point of view (and particularly, when the
sequence to be sorted is quite large), I think that doing fn:reverse after
doing fn:sort would certainly be more time consuming (than fn:sort flagged
with 'descending').


> [1] https://www.w3.org/TR/xpath-30/#id-arithmetic
>


-- 
Regards,
Mukul Gandhi

Received on Saturday, 16 January 2021 11:29:18 UTC