Page 1 of 1
Sorting things other than a simple list
Posted: 05 Sep 2014 20:56
by dah
Hi,
I have a map where the values are counts. I'd like to get a list of the keys which is sorted by these counts.
Is there a way to do this? It seems the 'sort' function isn't usefull here, am I right?
Best regards,
Daniel
Re: Sorting things other than a simple list
Posted: 05 Sep 2014 21:17
by kintrupf
dah wrote:Hi,
I have a map where the values are counts. I'd like to get a list of the keys which is sorted by these counts.
Is there a way to do this? It seems the 'sort' function isn't usefull here, am I right?
Oh, you'll need the
sort function

Use it in combination with the
getMapKeys function. This will result in a sorted list of all keys of the map.
Somthing like this in a
script action or an
expression condition:
Code: Select all
sortedList = sort(getMapKeys(yourMap));
Re: Sorting things other than a simple list
Posted: 06 Sep 2014 20:48
by dah
Thanks, but I need a list of the keys that is sorted by the values of the map (the counts).
For example:
map = {
foo: 3,
bar: 1,
baz: 10
}
would result in the list:
- bar
- foo
- baz