import java.util.ArrayList; import java.util.Comparator; import java.util.List; import sort.InsertionSort; import sort.QuickSort; import sort.SortableArray; import sort.SortableList; /* * Created on 24 oct. 2004 * */ /** * @author baudon * */ public class TestSort { public static void main(String[] args) { List largs = new ArrayList(); for (int i = 0; i < args.length; i++) { largs.add(args[i]); } new QuickSort().doSort(new SortableArray(args, new Comparator() { public int compare(Object arg0, Object arg1) { return -((Comparable) arg0).compareTo(arg1); } })); for (int j = 0; j < args.length; ++j) { System.out.print(args[j] + " "); } System.out.println(); new InsertionSort().doSort(new SortableList(largs, new Comparator() { public int compare(Object arg0, Object arg1) { String s0 = (String) arg0; String s1 = (String) arg1; if (s0.length() == s1.length()) { return s0.compareTo(s1); } else { return (s0.length() > s1.length() ? 1 : -1); } } })); for (int j = 0; j < args.length; ++j) { System.out.print(largs.get(j) + " "); } System.out.println(); } }