I have an array similar to this:
a = [
[0, {:a=>"31", :b=>"21"}],
[1, {:a=>"32", :b=>"11"}],
[1, {:a=>"25", :b=>"19"}],
[0, {:a=>"12", :b=>"10"}]
]
And I want to sort it by the first element of each row or by the various elements of the hash (2nd element in the row).
to sort by the first item in the Array:
to sort by the first item in the Hash:
or you could sort by a given key of the hash:
If you want to sort by the first array value, and then by the first entry in the hash, as a secondary search criteria, the answer is: