How to sort an array of hashes in ruby
Simples:
array_of_hashes.sort_by { |hsh| hsh[:zip] }
Note:
When using sort_by
you need to assign the result to a new variable: array_of_hashes = array_of_hashes.sort_by{}
otherwise you can use the "bang" method to modify in place: array_of_hashes.sort_by!{}
sorted = dataarray.sort {|a,b| a[:zip] <=> b[:zip]}