Skip to content

Instantly share code, notes, and snippets.

@flazz
Created October 26, 2009 20:05
Show Gist options
  • Save flazz/218985 to your computer and use it in GitHub Desktop.
Save flazz/218985 to your computer and use it in GitHub Desktop.
#!/usr/bin/env io
List do (
pivot := method(first)
upper := method(select(x, x < pivot))
lower := method(select(x, x > pivot))
qsort := method(if(size > 1, lower qsort append(pivot) appendSeq(upper qsort), clone))
)
writeln("building list")
a := list()
10000 repeat(i, a append(i asString))
a shuffle
testSort := method(
a clone doMessage(call argAt(0))
)
writeln("Testing")
for(i, 0, 3,
writeln("testQSort ", Date secondsToRun(testSort(qsort)))
writeln("testSort ", Date secondsToRun(testSort(sortInPlace)))
"" println
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment