I am having a hell of a time finding an answer to this one.
I would like to have a hash in JavaScript, like so:
const hash = {
a: 'A',
c: 'C',
b: 'B'
}
and I would like to sort the object by the value, such that it might become:
const hash = {
a: 'A',
b: 'B',
c: 'C',
}
now, I realize that POJSOs don't guarantee the order of their keys, so I was thinking of using immutableJS
or some object that will guarantee the order of the keys in the hash.
so I am looking for something like:
var newHash = Immutable.Map(hash).sortBy(function(key,val){
return val;
});
But I don't believe this exists. is this too much to ask? How can I find this functionality?