This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name | ### sort()
Examples |
    float[] a = { 3.4, 3.6, 2, 0, 7.1 };
    a = sort(a);
    println(a);
    // Prints the contents of the sorted array:
    // [0] 0.0
    // [1] 2.0
    // [2] 3.4
    // [3] 3.6
    // [4] 7.1
    String[] s = { "deer", "elephant", "bear", "aardvark", "cat" };
    s = sort(s);
    println(s);
    // Prints the contents of the sorted array:
    // [0] "aardvark"
    // [1] "bear"
    // [2] "cat"
    // [3] "deer"
    // [4] "elephant"
    String[] s = { "deer", "elephant", "bear", "aardvark", "cat" };
    s = sort(s, 3);
    println(s);
    // Prints the contents of the array, with the first 3 elements sorted:
    // [0] "bear"
    // [1] "deer"
    // [2] "elephant"
    // [3] "aardvark"
    // [4] "cat"
Description | Sorts an array of numbers from smallest to largest, or puts an array of words in alphabetical order. The original array is not modified; a re-ordered array is returned. The count parameter states the number of elements to sort. For example, if there are 12 elements in an array and count is set to 5, only the first 5 elements in the array will be sorted.
Syntax |
    sort(list)
    sort(list, count)
Parameters |
list | String[], float[], int[], char[], or byte[]: array to sort
count | int: number of elements to sort, starting from 0
Returns | byte[], char[], int[], float[], or String[]
Related | reverse()

Updated on October 26, 2013 08:58:31pm PDT