I have an array of objects in Java. Let's say Product products[]
.
Each of those products have a price, for example, product.getPrice()
.
What's the best way I can order that product array by the price so I can call, products[0]
for the most expensive product and products[products.length-1]
for the least expensive?