Skip to content

Instantly share code, notes, and snippets.

@daveshah
Last active December 28, 2015 20:19
Show Gist options
  • Save daveshah/7556292 to your computer and use it in GitHub Desktop.
Save daveshah/7556292 to your computer and use it in GitHub Desktop.
Quicksort Implementation in Scala
def quickSort(xs: Array[Int]) : Array[Int] = {
if(xs.length <= 1) xs
else {
val pivot = xs(xs.length / 2)
Array.concat(
quickSort(xs filter (pivot >)),
xs filter( pivot == ),
quickSort(xs filter (pivot <))
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment