function swap(array, a, b)
{
tmp=array[a];
array[a]=array[b];
array[b]=tmp;
}
function partition(array, begin, end, pivot)
{
piv=array[pivot];
swap(array, pivot, end-1);
store=begin;
for(ix=begin; ix < end-1; ix++) {
if(array[ix]<=piv) {
swap(array, store, ix);
store++;
}
}
swap(array, end-1, store);
return store;
}
function qsort(array, begin, end)
{
if(end-1>begin) {
pivot=begin+(end-begin) / 2;
pivot=partition(array, begin, end, pivot);
qsort(array, begin, pivot);
qsort(array, pivot+1, end);
}
}
a = [1,2,10,0,12,34,5,3,3,4,1,23,4];
s1 = '';
for (i=0; i < a.Length; i++)
s1 = s1+' '+a[i];
qsort(a, 0, a.Length);
s='';
for (i=0; i < a.Length; i++)
s = s+' '+a[i];
Test.AreEqual(' 0 1 1 2 3 3 4 4 5 10 12 23 34', s);