[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sort List of Maps By Key Value

Subject: 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
 Sort List of Maps By Key Value
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.