Needs["CSM`SortAux`"]

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

y
gr

maxl = 8

thin = 0.002
thick= 0.01
gray = 0.7
gap  = 0.25

QuickSort[list_] :=
	Module[{l = list, res},
		y = -1; gr = {Thickness[thin]};
		res = QSort[l, 1, Length[list]];
		Show[ Graphics[gr], Axes->None,
		      AspectRatio->Automatic,
		      PlotRange->{{0.9, maxl+1.1}, {y+1+gap, 0.1}}
		    ];
		res
	]

SetAttributes[QSort, HoldFirst]

QSort[l_, n0_, n1_] := l /; n0 >= n1

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-- ];
			draw[l, n0, n1, i, j];
			If[ i >= j, Break[] ];
			swap[l, i, j];
			i++; j--
		];
		QSort[ l, n0, i-1 ];
		QSort[ l, j+1, n1 ];
		l
	]

rect[{x0_, y0_}, {x1_, y1_}] :=
	Line[{{x0, y0}, {x1, y0}, {x1, y1}, {x0, y1}, {x0, y0}}]

draw[l_, n0_, n1_, i_, j_] :=
	Module[{g1, g2},
	Which[
	i < j, 
	  g1 = {GrayLevel[gray], Rectangle[{i, y}, {i+1, y+1}],
	        Rectangle[{j, y}, {j+1, y+1}]},
	i == j, g1 = {Thickness[thick], rect[{i, y}, {i+1, y+1}],
	              GrayLevel[gray], Rectangle[{i, y}, {i+1, y+1}]},
	i > j,
	  g1 = {Thickness[thick], Line[{{i, y}, {i, y+1}}]}
	];
	g2 = Table[{rect[{x, y}, {x+1, y+1}],
	            Text[l[[x]], {x+1/2, y+1/2}]},
	           {x, n0, n1}];
	AppendTo[ gr, {g1, g2} ];
	y -= 1 + gap;
	]
