快排

public class Test05 {

    static int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 10, 19, 18, 17, 16 ,23,45,43};

    public static void main(String[] args) {
        sort(0,a.length-1);
        for(int b : a){
            System.out.print(b+" ");
        }
    }

    public static void sort(int low, int height) {
        if(low >height)
            return;
        int k = a[low];
        int i = low, j = height;
        while (i < j) {
            for (; i < j && a[j] >= k; j--)
                ;
            a[i] = a[j];
            for (; i < j && a[i] <= k; i++)
                ;
            a[j] = a[i];
        }
        a[i] = k;
        sort(low,i-1);
        sort(i+1,height);
    }
}
原文地址:https://www.cnblogs.com/YESheng/p/3659396.html