Platypus logo

Examples Using The QuickSort Class Library

This directory (docs/examples) contains sample code to use the QuickSort. To use QuickSort in your development environment, ensure the Jar file (QuickSort.jar) is included in your CLASSPATH.

Within the code, variables and methods used by QuickSort are in bold . If you want to compile and run the examples, you can find the .java files in this directory (docs/examples).

  • Example 1 Java Code

    This example demonstrates the way in which any type of data can be sorted by the QuickSort class.

    The following is the result of running the command java Example1:

    Current order of the Vector:

    Date of Birth: Sun Jan 04 15:50:34 EST 1970 - Smith, John.
    Date of Birth: Mon Jan 05 05:54:19 EST 1970 - Edwards, Wayne.
    Date of Birth: Wed Dec 31 22:22:01 EST 1969 - Smith, Mary.
    Date of Birth: Wed Dec 31 19:09:13 EST 1969 - Kennedy, Fred.
    Date of Birth: Wed Dec 31 19:00:12 EST 1969 - Caveman, Joe.
    Date of Birth: Fri Jan 02 05:24:49 EST 1970 - Presto, Elvis.
    Date of Birth: Tue Jan 06 05:33:09 EST 1970 - Ryan, Chris.
    Date of Birth: Tue Jan 06 00:57:45 EST 1970 - Henderson, Michael.
    Date of Birth: Sat Jan 03 12:11:16 EST 1970 - Marshall, Brad.
    Date of Birth: Tue Jan 06 01:15:45 EST 1970 - Wood, David.

    Sorted order of the Vector:

    Date of Birth: Wed Dec 31 19:00:12 EST 1969 - Caveman, Joe.
    Date of Birth: Wed Dec 31 19:09:13 EST 1969 - Kennedy, Fred.
    Date of Birth: Wed Dec 31 22:22:01 EST 1969 - Smith, Mary.
    Date of Birth: Fri Jan 02 05:24:49 EST 1970 - Presto, Elvis.
    Date of Birth: Sat Jan 03 12:11:16 EST 1970 - Marshall, Brad.
    Date of Birth: Sun Jan 04 15:50:34 EST 1970 - Smith, John.
    Date of Birth: Mon Jan 05 05:54:19 EST 1970 - Edwards, Wayne.
    Date of Birth: Tue Jan 06 00:57:45 EST 1970 - Henderson, Michael.
    Date of Birth: Tue Jan 06 01:15:45 EST 1970 - Wood, David.
    Date of Birth: Tue Jan 06 05:33:09 EST 1970 - Ryan, Chris.

  • Example 2 Java Code

    This example demonstates using the QuickSort class to sort a Vector of Strings.

    The following is the result of running the command java Example2:

    Unsorted values:
    sort_9 sort_0 sort_2 sort_7 sort_1 sort_5 sort_8 sort_3 sort_6 sort_4

    QuickSort.quickSort(vector_to_sort, QuickSort.STRING);

    Sorted values:
    sort_0 sort_1 sort_2 sort_3 sort_4 sort_5 sort_6 sort_7 sort_8 sort_9

  • Example 3 Java Code

    This example demonstates using the QuickSort class to sort a Vector of Integer objects.

    The following is the result of running the command java Example3:

    Unsorted values:
    6 2 8 4 9 5 3 7 0 1

    QuickSort.quickSort(vector_to_sort, QuickSort.INT);

    Sorted values:
    0 1 2 3 4 5 6 7 8 9

  • Plugged In Open Source logo