bendy303 4 Posted February 5 Hi is there a way to sort a hashmap by values instead of keys? or do we have to convert it to an array first? cheers Ben Share this post Link to post Share on other sites
POLPOX 778 Posted February 5 A HashMap cannot be sorted. It is how a HashMap works so you need an array instead. 1 Share this post Link to post Share on other sites
bendy303 4 Posted February 5 1 minute ago, POLPOX said: A HashMap cannot be sorted. It is how a HashMap works so you need an array instead. cheers thanks buddy Share this post Link to post Share on other sites
bendy303 4 Posted February 6 On 2/5/2024 at 3:14 PM, POLPOX said: A HashMap cannot be sorted. It is how a HashMap works so you need an array instead. Hi Polpox quick question on arrays instead. how can I sort by the second value instead of the first? so I have sort working, if I have values first [[0.50425,"arms"],[0.0345939,"torso"],[0,"legs"],[0,"head"]] but in instances where all values are the same: [[1,"arms"],1,"torso"],[1,"legs"],[1,"head"]] I want to then sort by the strings (bodyparts) help appreciated cheers Ben Share this post Link to post Share on other sites
bendy303 4 Posted February 6 37 minutes ago, bendy303 said: Hi Polpox quick question on arrays instead. how can I sort by the second value instead of the first? so I have sort working, if I have values first [[0.50425,"arms"],[0.0345939,"torso"],[0,"legs"],[0,"head"]] but in instances where all values are the same: [[1,"arms"],1,"torso"],[1,"legs"],[1,"head"]] I want to then sort by the strings (bodyparts) help appreciated cheers Ben OK!! I think I figured it out. Use BIS_fnc_sortBy instead of sort. So: _total = [[1,"arms"],1,"torso"],[1,"legs"],[1,"head"]]; _test = [_total, [], {_x select 1}, "ASCEND"] call BIS_fnc_sortBy; Share this post Link to post Share on other sites