|
Subject: [xsl] Sort List of Maps By Key Value From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 29 Sep 2018 17:57:35 -0000 |
Using XPath 3 maps:
I have a list of maps where all the maps have a key on whose value I want to sort the list of maps.
Brute force I can do:
let $sortedKeys := $maps ! map:get(., 'sortonme') => sort()
for $key in $sortedKeys
let $key := .
let $map := $maps ! if (map:get(., 'sortonme') eq $key) then . else ()
return func:operate-on-map($map)
But this seems unnecessarily brutish.
I'm still trying to get my head around how to use the "?" operator as well as functional mappings and whatnot.
So is there a more compact or clearer way to order a set of maps based on an order applied to the values of a given entry that exists in each map?
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Gale-Shapley algorithm an, Matthieu RICAUD-DUSS | Thread | Re: [xsl] Sort List of Maps By Key , Martin Honnen martin |
| Re: [xsl] Gale-Shapley algorithm an, Matthieu RICAUD-DUSS | Date | Re: [xsl] Sort List of Maps By Key , Martin Honnen martin |
| Month |