خرید بک لینک

Vote count: 0

I am sorting an array filled with hashes using the below:

array.sort_by {|hash| hash[:key_name]}

When I sort by array[:damagemin] all the numbers sort except the lone 4-digit number which is being sorted as if it is a "1":

bydamagemin
=> [{:heroname=>"Bastion", :winrate=>"53.6%", :damagemin=>"1079", :herokd=>"2.23:1"},
 {:heroname=>"Lúcio", :winrate=>"57.6%", :damagemin=>"328", :herokd=>"1.51:1"},
 {:heroname=>"Mei", :winrate=>"51%", :damagemin=>"451", :herokd=>"1.95:1"},
 {:heroname=>"Reinhardt", :winrate=>"51.3%", :damagemin=>"463", :herokd=>"1.28:1"}]

How can I resolve this issue and sort the numbers from highest to lowest regardless of their length?

asked 15 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 12 تير 1395 ساعت: 11:29

صفحه بندی