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

python - argument must be rect style object - Pygame -

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

c# - Better 64-bit byte array hash -