I have a List of Objects like List p.I want to sort this list alphabetically using Object name field. Object contains 10 field and name field is o
List p
Using a selection Sort
for(int i = list.size() - 1; i > 0; i--){ int max = i for(int j = 0; j < i; j++){ if(list.get(j).getName().compareTo(list.get(j).getName()) > 0){ max= j; } } //make the swap Object temp = list.get(i); list.get(i) = list.get(max); list.get(max) = temp; }