I have an array that looks like the following:
[
{ type: 'A', price: '0.01' },
{ type: 'B', price: '4.23' },
{ type: 'D', price: '2.29' },
{ type: 'B', price: '3.38' },
{ type: 'C', price: '1.15' }
]
I need to group these by type and then sort them by ascending price. I can half solve this problem by doing the following:
boards.sort_by {|e| [e['type'], e['price'].to_f]}
Unfortunately, this sorts the types alphabetically when they should be sorted BADC
How do I sort the array by the pre-determined rules?
Output: