/*  SelectionSort.java
 *
 *  Written by:  Mark Masse
 *  Date:  Nov. 5, 1995
 *  Updated by:  Bindu Wavell
 *  Date:  April 8th, 1996
 *  
 *  This version of sort thread implements Selection Sort.  It is called
 *  by the ClassNotes+ Demo package.
 */
class SelectionSort extends CNSortAlgorithm {
  void sort(SortItem array[], int num_elems) {
    int i, j, min;
    
    
                                                   demo.pause(demo.BLOCK_LOOP);
    for(i = 0; i < num_elems - 1; i++) {
      min = i;
      for(j = i + 1; j < num_elems; j++) {
        if(array[j].getValue() < array[min].getValue())
          min = j;
      }
      demo.swap(min, i);
	                                           demo.highlightRange(min, i);
                                            demo.pause(demo.BLOCK_SINGLE_STEP);
    }
  }
} /* end Sort_Thread */

