Source of SortLines.java


  1: import java.util.Arrays;

  3: /**
  4:  * A program to sort lines according to their natural sorting order --
  5:  * whatever that may be!
  6:  *
  7:  * @author Mark Young (A00000000)
  8:  */
  9: public class SortLines {

 11:     public static void main(String[] args) {
 12:         // create list of Students
 13:         Line[] ss = new Line[] {
 14:                         new Line(14.2),
 15:                         new Line(0.2),
 16:                         new Line(7.1),
 17:                         new Line(1.5)
 18:                     };

 20:         // report original
 21:         System.out.println("\nHere is a list of Lines:");
 22:         System.out.println("\t" + Arrays.toString(ss));

 24:         // sort and present sorted
 25:         Arrays.sort(ss);
 26:         System.out.println("\nHere is that same list, sorted by length:");
 27:         System.out.println("\t" + Arrays.toString(ss));
 28:         System.out.println();
 29:     }

 31: }