Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Created June 20, 2010 06:36
Show Gist options
  • Save yuya-takeyama/445613 to your computer and use it in GitHub Desktop.
Save yuya-takeyama/445613 to your computer and use it in GitHub Desktop.
def qsort(arr: Array[Int]): Array[Int] = arr.length match {
case n if n <= 1 => arr
case _ => {
var pivot = arr(0)
qsort(arr.filter(x => x < pivot)) ++ arr.filter(x => x == pivot) ++ qsort(arr.filter(x => x > pivot))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment