What is looks like is that you actually have a hash containing some Arrays. Cleaning it up I assume it should look something like this:
hash = {:time_frame=>"Today", :locations=>["Tampa", "Atlanta", "California", "Georgia", "South Lake Union"], :local_totals=>[10000.0, 30,000, 70000, 50000, :expenses=>[2000, 10000, 4000, 6000]}
Assuming that is correct, you can do something like this to solve you question:
hash[:locations].zip(hash[:local_totals]).sort_by(&:last)
This assumes that the locations in the arrays match up.
I realize that by answering this I’m encouraging bad questions but it was one of those situations where I looked at it and wondered how I’d solve it then figured I might as well post my solution. 🙂
MINASWAN 🙂
Or if you want to solve it as written:
@summaries[0][:locations].zip(@summaries[0][:local_totals]).sort_by(&:last).reverse
3
solved ruby how to sort this Hash of Arrays [closed]