import java.util.Random; public class MySort { // Sort the array a[] in ascending order using an insertion sort. static void sort(Compare a[]) { for (int i = 1; i < a.length; i++) { // a[0..i-1] is sorted; insert a[i] in the proper place int j; Compare x = a[i]; for (j = i - 1; j >= 0 && !a[j].isLess(x); j--) { a[j + 1] = a[j]; } // now a[0..j] are all <= x and a[j+2..i] are > x a[j + 1] = x; } } // Test program to test sort public static void main(String args[]) { if (args.length != 1) { System.out.println ("usage: java SortTest array-size"); System.exit (1); } int size = Integer.parseInt (args[0]); Room test[] = new Room[size]; Random r = new Random(); // YOU DO: CREATE test Array with "size" number of elements System.out.println ("before"); for (int i = 0; i < size; i++) System.out.print (" " + test[i]); System.out.println (); sort (test); System.out.println ("after"); for (int i = 0; i < size; i++) System.out.print (" " + test[i]); System.out.println (); System.exit (0); } }