I have an OrderedHash, generated from the answer here that looks like this:
<OrderedHash {2=>"534.45",7=>"10",153=>"85.0"}>
So, I need to sort the hash by the second value, in descending order. I tried this:
var.sort! {|a,b| b[1] <=> a[1]}
NoMethodError: undefined method `sort!' for #<ActiveSupport::OrderedHash:0x127a50848>
How can I reorder this OrderedHash?
Well, I think you can simply use
:order => 'sum_deal_price ASC'in thesumcall of the original answer.But you can also do it in Ruby, it’s just a bit trickier: