/**
*  Demonstrates using the QuickSort class to sort numbers.
*/

import com.pisoftware.quicksort.*;
import com.pisoftware.quicksort.event.*;

import java.util.*;

public class Example3 {

  static private int[] sort_values = {
    6,
    2,
    8,
    4,
    9,
    5,
    3,
    7,
    0,
    1
  };


  /**
  *    Start the example.
  */
  public static void main(String[] args) {

    System.out.println("Unsorted values:");

    // QuickSort operates on Vectors.  Because a Java Vector won't
    // allow you to insert primitive types (such as an int), we have
    // to wrap these values in Integer objects.

    Vector vector_to_sort = new Vector();
    for(int i=0; i<sort_values.length; i++) {

      Integer the_integer = new Integer(sort_values[i]);
      vector_to_sort.addElement(the_integer);
      System.out.print("  "+the_integer);

    }
    System.out.println("");

    // Use the QuickSort class to sort the Integers

    System.out.println("QuickSort.quickSort(vector_to_sort, QuickSort.INT);");
    QuickSort.quickSort(vector_to_sort, QuickSort.INT);
    System.out.println("Sorted values:");

    for(int i=0; i<vector_to_sort.size(); i++) {

       // Retrieve the int as an Integer object
       // (see the description above as to why these are Integer and not int)

       Integer the_integer = (Integer) vector_to_sort.elementAt(i);

       System.out.print("  "+the_integer);

    }

  }


}