Python: Quick sort
9. Quick Sort
Write a Python program to sort a list of elements using the quick sort algorithm.
Note : According to Wikipedia "Quicksort is a comparison sort, meaning that it can sort items of any type for which a "less-than" relation (formally, a total order) is defined. In efficient implementations it is not a stable sort, meaning that the relative order of equal sort items is not preserved. Quicksort can operate in-place on an array, requiring small additional amounts of memory to perform the sorting."
Sample Solution:
Python Code:
Sample Output:
[17, 20, 26, 31, 44, 54, 55, 77, 93]
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to implement quick sort and print the pivot element chosen at each recursive call.
- Write a Python script to sort a list using quick sort and measure the recursion depth required for sorting.
- Write a Python program to implement quick sort using the Lomuto partition scheme and compare its performance with Hoare's partition scheme.
- Write a Python function to sort a list of strings using quick sort and ensure the sort is case-insensitive.
Go to:
Previous: Write a Python program to sort a list of elements using the merge sort algorithm.
Next: Write a Python program Program for counting sort.
Python Code Editor :
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.