static void selectionSort ( double [ ] a , int n ) {
  double temp ;
  int chosen ;

  for ( int leftmost = 0 ; leftmost < n - 1 ; leftmost ++ ) {
    chosen = leftmost ;
    for ( int j = leftmost + 1 ; j < n ; j ++ )
      if ( a [ j ] < a [ chosen ] ) chosen = j ;
    temp = a [ chosen ] ;
    a [ chosen ] = a [ leftmost ] ;
    a [ leftmost ] = temp ;
  }
}