Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,47 @@
class QuickSort {
function : Main(args : String[]) ~ Nil {
array := [1, 3, 5, 7, 9, 8, 6, 4, 2];
Sort(array);
each(i : array) {
array[i]->PrintLine();
};
}
function : Sort(array : Int[]) ~ Nil {
size := array->Size();
if(size <= 1) {
return;
};
Sort(array, 0, size - 1);
}
function : native : Sort(array : Int[], low : Int, high : Int) ~ Nil {
i := low; j := high;
pivot := array[low + (high-low)/2];
while(i <= j) {
while(array[i] < pivot) {
i+=1;
};
while(array[j] > pivot) {
j-=1;
};
if (i <= j) {
temp := array[i];
array[i] := array[j];
array[j] := temp;
i+=1; j-=1;
};
};
if(low < j) {
Sort(array, low, j);
};
if(i < high) {
Sort(array, i, high);
};
}
}