How to find the minimum value from the ranges in array of hashes in ruby? -


i have below array of hashes

z = {"range"=>[{"10-50"=>"5"}, {"50-100"=>"15"}, {"100-150"=>"25"}]}  

how can output 10

you can try following:

z["range"].map(&:keys).flatten.map(&:to_i).min #=> 10 

demo


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -