I would like to find the underscore of the minimum value. For instance:
var my_hash = {'0-0' : {value: 23, info: 'some info'},
'0-23' : {value: 8, info: 'some other info'},
'0-54' : {value: 54, info: 'some other info'},
'0-44' : {value: 34, info: 'some other info'}
}
find_min_key(my_hash); => '0-23'
How can I do this using underscorejs?
I tried:
_.min(my_hash, function(r){
return r.value;
});
I also try to sort it (and then get the first element):
_.sortBy(my_hash, function(r){
return r.value;
})
But it returns an array with numeric indices, so my hash keys are lost.
source
share