from random import randint
import sys
import time

def sort(arr, start, length):

	if length <= 1:
		return arr

	pivot_index = randint(start, length-1)
	pivot = arr[pivot_index]
	swap(arr, start, pivot_index)

	i = j = start + 1

	while j < length:
		if arr[j] < pivot:
			swap(arr, j, i)
			i += 1
		j += 1

	swap(arr, start, i-1)

	first_part = sort(arr[start:i], start, i)
	second_part = sort(arr[i:length], start, length - i - 1)

	return first_part + second_part


def swap(arr, x, y):
	temp = arr[x]
	arr[x] = arr[y]
	arr[y] = temp

def main(arr_len):

	unsorted = [randint(0, 1000000) for n in range(arr_len)]
	start_time = time.time()
	sort(unsorted, 0, len(unsorted)-1)
	print 'unsorted: %f' % (time.time() - start_time)

	unsorted = list(range(arr_len))
	start_time = time.time()
	sort(unsorted, 0, len(unsorted)-1)
	print 'sorted: %f' % (time.time() - start_time)


if __name__ == '__main__':

	try:
		arr_len = int(sys.argv[1])
	except (IndexError, ValueError):
		print 'Format: python quicksort.py <array-length>'

	main(arr_len)

@@ -541,62 +541,37 @@
 def 
-main(arr_len):%0A%0A%09unsorted = %5Brandint(0, 1000000) 
+check(arr):%0A%09print arr%0A%09
 for 
-n
+i
  in 
@@ -580,149 +580,133 @@
 nge(
-arr_len)%5D%0A%09start_time = time.time()%0A%09sort(unsorted, 0, len(unsorted)-1)%0A%09print 'unsorted: %25f' %25 (time.time() - start_time)%0A%0A%09unsorted = list(
+len(arr)-1):%0A%09%09if arr%5Bi%5D %3E arr%5Bi+1%5D:%0A%09%09%09return False%0A%09return True%0A%0Adef main(arr_len):%0A%0A%09unsorted = %5Brandint(0, 100) for n in 
 rang
@@ -715,17 +715,17 @@
 arr_len)
-)
+%5D
 %0A%09start_
@@ -744,16 +744,28 @@
 time()%0A%09
+print check(
 sort(uns
@@ -794,56 +794,8 @@
 )-1)
-%0A%09print 'sorted: %25f' %25 (time.time() - start_time
 )%0A%0A%0A

Add check function to quicksort