` Scriptol examples
` Basic quick sort function
` www.scriptol.net


` array is alias for the original array sorted

void quickSort(alias array theArray, int first, int last)
    int f = first
    int l = last
    dyn item = theArray[(f + l) / 2]

    do
        while theArray[f] < item let  f + 1
        while item < theArray[l] let  l - 1
        if f <= l
            swap(theArray[f], theArray[l])
            f + 1
            l - 1
        /if
    /do while f <= l

    if first < l ?  quickSort(theArray, first, l)
    if f < last  ?  quickSort(theArray, f, last)

return

array theArray = {10, 5, 8, 1, 126, 33, 12, 5, 7, 1000, 2}
print "qsort - Sorting array of integer"
print "before:"; theArray.display()
quickSort(theArray, 0, theArray.size() - 1)
print "after:"; theArray.display()