I have a array of hash something like
[{a1: 'a', b1: 'b'},{a1: 'c', b1: 'b'},{a1: 's', b1: 'cq'}]
I want to sort the array in the ascending value of b1 and return an array. Sorry if its easy but got confuse with the logic.
I have a array of hash something like
[{a1: 'a', b1: 'b'},{a1: 'c', b1: 'b'},{a1: 's', b1: 'cq'}]
I want to sort the array in the ascending value of b1 and return an array. Sorry if its easy but got confuse with the logic.
Following will return you an array sorted based on b1
array_of_hashes.sort_by { |hsh| hsh[:b1] }