Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Created April 3, 2015 12:45
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 akhileshs/60331456cdae16464a30 to your computer and use it in GitHub Desktop.
Save akhileshs/60331456cdae16464a30 to your computer and use it in GitHub Desktop.
simple quick sort
scala> def qsort(xs: List[Int]): List[Int] = {
| if (xs.length <= 1) xs
| else {
| val pivot = xs(xs.length / 2)
| qsort(xs filter (_ < pivot)) ++ List(pivot) ++ qsort(xs filter (_ > pivot))
| }
| }
qsort: (xs: List[Int])List[Int]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment