I have an array of arrays in Ruby:
price_list = [
['Brand-1', 'Model-1', 100.00],
['Brand-1', 'Model-2', 200.00],
['Brand-2', 'Model-1', 10.00],
['Brand-2', 'Model-2', 20.00],
['Brand-1', 'Model-1', 110.00],
['Brand-1', 'Model-2', 190.00],
['Brand-1', 'Model-3', 300.00],
...
['Brand-n', 'Model-n', 1234.00]
]
And I need to create new array with only unique products and minimal prices. Something like this:
new_price_list = [
['Brand-1', 'Model-1', 100.00],
['Brand-2', 'Model-1', 10.00],
['Brand-2', 'Model-2', 20.00],
['Brand-1', 'Model-2', 190.00],
['Brand-1', 'Model-3', 300.00],
...
['Brand-n', 'Model-n', 1234.00]
]
What is a fastest and most beautiful way to do this in Ruby?