I'm using a map
for counting the number occurrences of, for example, each possible value of the attr
attribute of the elem
nodes:
<root>
<elem attr="a"/>
<elem attr="b"/>
<elem attr="b"/>
<elem />
<elem attr="a"/>
<elem attr="c"/>
<elem attr="b"/>
</root>
fold-left(
//elem/@attr,
map{},
function($m,$a) {map:put($m, $a, sum((1, $m($a))))}
)
Resulting map:
{
"a": 2,
"b": 3,
"c": 1
}
Now, using this map
, I would like to sort the integer values in descending order and emit their associated key. The expected "output" would be:
b
a
c
How can I do it?