W3C home > Mailing lists > Public > public-xslt-40@w3.org > January 2021

Re: improvements to fn:sort functions

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Sat, 16 Jan 2021 16:58:48 +0530
Message-ID: <CABuuzNNbBc6HiLUj4XiywJY-SqzrGAmhuadyw4ojuLDk-0mwQA@mail.gmail.com>
To: Christian Grün <cg@basex.org>
Cc: public-xslt-40@w3.org
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

This archive was generated by hypermail 2.4.0 : Saturday, 16 January 2021 11:29:23 UTC