September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,27 @@
a = .array~Of(4, 65, 2, -31, 0, 99, 83, 782, 1)
say 'before:' a~toString( ,', ')
a = quickSort(a)
say ' after:' a~toString( ,', ')
exit
::routine quickSort
use arg arr -- the array to be sorted
less = .array~new
pivotList = .array~new
more = .array~new
if arr~items <= 1 then
return arr
else do
pivot = arr[1]
do i over arr
if i < pivot then
less~append(i)
else if i > pivot then
more~append(i)
else
pivotList~append(i)
end
less = quickSort(less)
more = quickSort(more)
return less~~appendAll(pivotList)~~appendAll(more)
end