import java.io.*;

public class Sort {

    public static void main(String[] args) {
	int n = args.length;
	String[] sortedArray = new String[n];

        /* 
           Write your code here. Use 2 loops (nested) taking items from
           args and putting them into sortedArray. So your assignment
           statement should look like:
           sortedArray[?] = args[?];
           where ? is some expression to calculate the array index.
           Also, you will need at least one if/then statement.
	*/

	// essentially, i is the location in the sortedArray that you want
	// to fill. j, on the other hand, is the index you are looking at in
	// the input list.
	// So, for each location (i) in the sortedArray, scan *all* the 
	// items in args and find the largest. Then copy it over and delete
	// it from the array.
	// NOTE THIS ONLY WORKS FOR A LIST OF POSITIVE INTEGERS
	for (int i = 0; i < args.length; i++) {
	    int biggest = -1;
	    int biggestIndex = -1;
	    for (int j = 0; j < args.length; j++) {
		int curValue = Integer.parseInt(args[j]);
		// Keeps track of the biggest number encountered so far
		// just like in Max.java
		if (curValue > biggest) {
		    biggest = curValue;
		    biggestIndex = j;
		}
	    }
	    // Copy the largest number found in the input list over to
	    // position i in sortedArray
	    sortedArray[i] = args[biggestIndex];
	    // This effectively deletes the item you just copied over from
	    // the input list so you don't re-add it durin the next
	    // iteration
	    args[biggestIndex] = "-1";
	}

        /* End of your code */

        /* this code will print out the values in sortedArray one by one */

	System.out.print("[");
	for (int i = 0; i < sortedArray.length; i++) {
	    System.out.print(" " + sortedArray[i]);
	    }
	    System.out.println(" ]");
    }

}
