'Ruby on rails how to take lowest/biggest number from array

I have an array with products, I need to display only 1 product, with the largest number in available_amount. How can i do this?

How do I iterate to display products with parameters:

- @part.wh_ps.sort_by(&:available_amount).each do |whp|

product number1: available_amount: 2;

product number2: available_amount: 5;



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source