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!{}
More Related Contents:
- How does Array#sort work when a block is passed?
- Please help me access nested array
- Algorithm for all subsets of Array
- How to sort in-place using the merge sort algorithm?
- Swift how to sort array of custom objects by property value
- VBA array sort function?
- Array slicing in Ruby: explanation for illogical behaviour (taken from Rubykoans.com)
- How to sort an array in Bash
- How to sort an array of custom objects by property value in Swift
- Sorting a multidimensionnal array in VBA
- Sort Objects in Array by date
- How do I insert an element at the correct position into a sorted array in Swift?
- Sorting a Swift array by ordering from another array
- How do I sort a swift array containing instances of NSManagedObject subclass by an attribute value (date)
- Swift sort an array with strings and numbers [duplicate]
- Generic function to sort array of class or struct by properties in Swift
- Sort an array according to the elements of another array
- How to sort an array in Ruby to a particular order?
- How to stable sort an array in swift?
- Regarding in-place merge in an array
- In Swift how can I sort one array based on another array?
- Excel VBA Quickest way to sort an array of numbers in descending order?
- MongoDB: How do I update a single subelement in an array, referenced by the index within the array?
- Algorithm to find k smallest numbers in array of n items
- Sort multidimensional array based on 2nd element of the subarray
- swift: modifying arrays inside dictionaries
- find pair of numbers in array that add to given sum
- What does $0 and $1 mean in Swift Closures?
- Create Chart from Array data and not range
- VBA – Returning array from Property Get