Skip to content

Instantly share code, notes, and snippets.

@akirillov
Created October 13, 2014 09:50
Show Gist options
  • Save akirillov/afbe61920fbc5b8b86cc to your computer and use it in GitHub Desktop.
Save akirillov/afbe61920fbc5b8b86cc to your computer and use it in GitHub Desktop.
QuickSort Example from "Scala by Example"
def sort(xs: Array[Int]): Array[Int] = {
if (xs.length <= 1) xs
else {
val pivot = xs(xs.length / 2)
Array.concat(sort(xs filter (pivot >)),xs filter (pivot ==), sort(xs filter (pivot <)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment