This is an efficient and concise implementation of in-place quicksort. Put the code-snippet QuickSort into your backpack and use in your own projects.
To understand how it works see this tutorial: http://www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/7-Sort/quick-sort2.html