Re: improvements to fn:sort functions

On Fri, Jan 15, 2021 at 1:54 PM Michael Kay <mike@saxonica.com> wrote:

> One approach might be to provide an extended form of the collation-key()
> function which can be used something like this:
>
> sort($data, by: sort-key([
>     map{'select': ->{last-name), 'order': 'ascending', 'collation':
> $surname-collation},
>     map('select': ->(first-name), 'order': 'descending', 'collation':
> $firstname-collation}]))
>

I really, like this idea, and would support adding it to XPath 4.0 (and
hence, to XSLT 4.0 as well). This shall make the XPath fn:sort function,
completely defined, with respect to having any number of sort keys.

(I think, you made a little typo at {last-name). You probably wanted, a
left parenthesis instead of a left curly brace.)


>
> But I wonder if it's really needed, since both XSLT and XQuery have this
> level of capability already. We don't have to put everything into XPath.
>

I think that, its quite likely, XPath (all versions) could be used in
contexts other than XSLT and XQuery (although, these are the most common
uses of XPath). I guess, adding the discussed fn:sort function
improvements, shall be helpful in long run.



-- 
Regards,
Mukul Gandhi

Received on Saturday, 16 January 2021 06:21:19 UTC