There is another concise and beautiful version
def qsort(arr):
if len(arr) <= 1:
return arr
else:
return qsort([x for x in arr[1:] if x < arr[0]]) + \
[arr[0]] + \
qsort([x for x in arr[1:] if x >= arr[0]])
# this comment is just to improve readability due to horizontal scroll!!!
Let me explain the above codes for details
pick the first element of array arr[0]
as pivot
[arr[0]]
qsort
those elements of array which are less than pivot with List Comprehension
qsort([x for x in arr[1:] if x < arr[0]])
qsort
those elements of array which are larger than pivot with List Comprehension
qsort([x for x in arr[1:] if x >= arr[0]])