//Script.NET examples //(c)2007-2009, Protsyk Petro, http://www.protsyk.com 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];