Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created March 28, 2013 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkitover/5267271 to your computer and use it in GitHub Desktop.
Save rkitover/5267271 to your computer and use it in GitHub Desktop.
#!/bin/sh
exec scala "$0" "$@"
!#
def quicksort(l: List[Int]): List[Int] = {
l match {
case Nil => Nil
case List(a, _*) => quicksort(l.tail.filter(_ < a)) ::: a :: quicksort(l.tail.filter(_ >= a))
}
}
println(quicksort(List(10, 6, 9, 3, 5, 11, 20, 2)).mkString(" "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment