import java.util.ArrayList; import java.util.List; public class SelectionSort { public SelectionSort() { } public void sort(List list) { if(list!=null){ for (int i = 0; i < list.size() - 1; i++) { int min = i; for (int j = i + 1; j < list.size(); j++) { if (list.get(j).intValue() <= list.get(min).intValue()) min = j; } swap(list, i, min); } System.out.println(list); } } // swap two elements in the array private void swap(List list, int i, int j) { int a = list.get(i); int b = list.get(j); list.set(i, b); list.set(j, a); } }