change order of arrayList
in
Programming Questions
•
2 years ago
This results in my case of having 4 time the location pune, 1 time singapore instand of the 5 original different locations.
- // change the order to have smaller locations drawn first
- ArrayList<Location> copyLocations = locations;
- Location copyLoc = copyLocations.get(2);
- locations.set(0, copyLoc);
- copyLoc = copyLocations.get(0);
- locations.set(1, copyLoc);
- copyLoc = copyLocations.get(4);
- locations.set(2, copyLoc);
- copyLoc = copyLocations.get(1);
- locations.set(3, copyLoc);
- copyLoc = copyLocations.get(3);
- locations.set(4, copyLoc);
1