Needs["CSM`SortAux`"]

QuickSort::usage = "QuickSort[list] sorts the list."

QuickSort[list_] := Module[ {l = list}, QSort[l, 1, Length[l]]; l ]

SetAttributes[QSort, HoldFirst]

QSort[l_, n0_, n1_]/; n0 >= n1 := l  (* nothing to do *)

QSort[l_, n0_, n1_] :=
	Module[{lm = l[[ Floor[(n0 + n1)/2] ]], i = n0, j = n1},
		While[ True,
			While[ l[[i]] < lm, i++ ];
			While[ l[[j]] > lm, j-- ];
			If[ i >= j, Break[] ];     (* l is partitioned *)
			swap[l, i, j];
			i++; j--
		];
		QSort[ l, n0, i-1 ]; (* recursion *)
		QSort[ l, j+1, n1 ]  (* recursion *)
	]
