<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package sort;

public class SelectionSort&lt;T extends Comparable&lt;T&gt;&gt; implements Sorter&lt;T&gt; {

   public void sort(T[] x) {

      for (int i = 0; i &lt; x.length - 1; i++) {
         // find min in x[i],...,x[n-1]
         int min = i;
         for (int j = i+1; j &lt; x.length; j++) {
            if (x[j].compareTo(x[min]) &lt; 0) min = j;
         }
         // swap
         T tmp = x[i];
         x[i] = x[min];
         x[min] = tmp;
      }
   }
}
</pre></body></html>