The Java Program: SelectionSort.java

  1 import Sorter;
  2 
  3 public class SelectionSort implements Sorter {
  4 
  5    public void sort (int [] a) {
  6       for (int i=0; i<a.length-1; i++) {
  7          int lowindex = i;
  8          for (int j=a.length-1; j>i; j--) {
  9             if (a[j] < a[lowindex]) lowindex = j;
 10          }
 11          int T = a[i];
 12          a[i] = a[lowindex];
 13          a[lowindex] = T;
 14 
 15       }
 16    }
 17 
 18 }