I need to sort the array list from highest to lowest based on the "value" and im really stuck :( basically in this project, they are gonna run a list of items and this method is supposed to put the one with the highest value first and so fort and im trying to use a selection sort. Thank for you help in advance :) here is what i have at the moment
public void pickMostExpensiveFirst(ArrayList<Item> totalListOfItems)
{
int max, i ,j;
Item temp;
for (i = 0; i < totalListOfItems.size() - 1; i++)
{
max = i;
for (j = i + 1; j < totalListOfItems.size(); j++)
{
if (totalListOfItems.get(max).getValue()
.compareTo(totalListOfItems.get(j).getValue()) > 0)
max = j;
}
temp = totalListOfItems.get(i);
totalListOfItems.set(i, totalListOfItems.get(max));
totalListOfItems.set(max, temp);
}
}