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
Sorting things other than a simple list
Moderator: Martin
Re: Sorting things other than a simple list
Oh, you'll need the sort functiondah 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?

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
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
For example:
map = {
foo: 3,
bar: 1,
baz: 10
}
would result in the list:
- bar
- foo
- baz