Python:

def quicksort(list):
	if len(list) == 0:
		return []
	else:
		return quicksort([x for x in list[1:] if x < list[0]]) + [list[0]] + quicksort([x for x in list[1:] if x >= list[0]])

Erlang:

quicksort([]) -> [];
quicksort([Pivot|T]) ->	quicksort([X || X <- T, X < Pivot]) ++ [Pivot] ++ quicksort([X || X <- T, X >= Pivot]).

This is so beautiful and concise.

Advertisements