/** * Demonstrates using the QuickSort class to sort Strings. */ import AU.net.plugged.sort.*; import AU.net.plugged.sort.event.*; import java.util.*; public class Example2 { static private String[] sort_values = { "sort_9", "sort_0", "sort_2", "sort_7", "sort_1", "sort_5", "sort_8", "sort_3", "sort_6", "sort_4" }; /** * Start the example. */ public static void main(String[] args) { // Because QuickSort operates on vectors, we need to insert the // Strings to sort into a Vector. System.out.println("Unsorted values:"); Vector vector_to_sort = new Vector(); for(int i=0; i<sort_values.length; i++) { // Insert each string to sort into the vector vector_to_sort.addElement(sort_values[i]); System.out.print(" "+sort_values[i]); } System.out.println(""); // Use the QuickSort class to sort the String objects System.out.println("QuickSort.quickSort(vector_to_sort, QuickSort.STRING);"); QuickSort.quickSort(vector_to_sort, QuickSort.STRING); System.out.println("Sorted values:"); for(int i=0; i<sort_values.length; i++) { // And finally print out the results. When the quickSort method // returns, the order of the Strings in the Vector is alphabetical. System.out.print(" "+(String)vector_to_sort.elementAt(i)); } } }