Hi,
I'm working with an arraylist, PO (private ArrayList <Book> myPO;). It contains a number of isbn values and my goal is to sort them in descending order.
This is how I'm doing it now:
public void isbnsort()
{
ArrayList temp = new ArrayList<Book>();
temp = myPO;
int counter = 0;
for(int i=0; i<myPO.size()-1; i++)
{
for(int k=0; i<myPO.size()-1; k++)
{
if(myPO.get(i).value()>=myPO.get(k).value())
counter++;
}
if(counter == myPO.size())
{
temp.add(myPO.get(i));
myPO.remove(i);
i = 0;
}
}
myPO = temp;
}
I don't know if this is the right way to do it, but there has to be an easier/more efficient way than this, I think. I would appreciate any help on how to do this in a better manner.
Sorry if I've made any silly errors here.
Thanks.