def sort(arr, length):
	
	if length == 1:
		return

	pivot = choose_pivot(arr, length)

	return (arr, length, pivot)


def choose_pivot(arr, length):

	return arr[0]


if __name__ == '__main__':
	
	unsorted = list(reversed(range(1000)))
	initial_len = len(unsorted)
	
	print sort(unsorted, initial_len)
from random import randint

def sort(arr, start, length):

	if length <= 1:
		return arr

	pivot = choose_pivot(arr, length)
	i = j = start + 1

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

	swap(arr, start, i-1)

	return (arr, length, pivot)


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


def choose_pivot(arr, length):

	return arr[0]


if __name__ == '__main__':
	
	unsorted = [randint(0, 100) for n in range(100)]
	print sort(unsorted, 0, len(unsorted)-1)

Add partition step and swap helper function
Add partition step and swap helper function

The data is partitioned iterating over the array and moving any
element less than the pivot value to the left part of the array.
This is done using an additional variable i that represents the
index of the smallest value greater than the pivot - any value
less than the pivot is swapped at the value at this index, which
is then incremented.

This version still uses a naive choice of pivot.
