Just like to paste this code:
Listsorted = new ArrayList (); RackPosition temp = null; int remove_index = -1; while(original.size() > 0) { temp = original.get(0); for (int i = 0; i < original.size(); i++ ) { RackPosition rp2 = original.get(i); if(temp.getPositionNumber().compareTo(rp2.getPositionNumber()) > 0) { temp = rp2; remove_index = i; } } System.out.println("Adding " + temp.getPositionNumber()); sorted.add(temp); // original.remove(temp); if(remove_index >= 0) { original.remove(remove_index); } remove_index = 0; }