// read in a list of batting averages (doubles) as command line arguments 
public class sort10000 {
    public static void main (String[] args) {
        
	

        double[] ba = new double [10000]; // allocate space for each command line argument 
		
        for (int i = 0; i< ba.length; i++) {
            ba[i] = 10000 - i; // force a long sort  
            }


       // sort the array - from low to high 
       // First find the lowest value, put it in ba[0], 
       // fint the next lowest value, put it in ba[1]..and so on
       // Efficiency is not a consideration here 
       for (int i = 0; i < (ba.length - 1); i++) {
           for (int j = i+1; j < ba.length; j++) {
               if (ba[i] > ba[j]) { // switch the two 
                  double temp = ba[i]; // save it 
                  ba[i] = ba[j]; // move lower number toward start 
                  ba[j] = temp;  // move higher numbers toward end
                  } 
                } // j loop
            } // i loop

        System.out.println("\nThe sorted array (every 50th element:\n"); 
	for (int i = 0; i< ba.length; i=i+50) {
            System.out.printf("Element [%d] =  %1.3f \n", i, ba[i]);  

               // notice this uses printf and I want the batting averages to always 
               // show 3 decimal places 
            }

    }
}