added port of sedgewick's java quicksort code