Skip to content

Instantly share code, notes, and snippets.

@oreillyross
Created May 20, 2015 09:34
Show Gist options
  • Save oreillyross/7750a9770a6d86400738 to your computer and use it in GitHub Desktop.
Save oreillyross/7750a9770a6d86400738 to your computer and use it in GitHub Desktop.
qsort algorithm in Scala
def qsort[T <% Ordered[T]](list: List[T]): List[T] = {
list match {
case Nil => Nil
case x:: xs =>
val (before, after) = xs partition (_ < x )
qsort (before) ++ (x :: qsort(after))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment