package sort.manysort; import sort.test.Command; public class SelectionSort implements Command { @Override public void sorting(Integer[] S) { int n = S.length; int temp, smallest; for (int i = 0; i < n - 1; i++) { smallest = i; for (int j = i + 1; j < n; j++) { if (S[j] < S[smallest]) smallest = j; } // now exchange S[i] and S[smallest] temp = S[i]; S[i] = S[smallest]; S[smallest] = temp; } } @Override public String getName() { return "Selection"; } }