Created
October 13, 2014 09:50
-
-
Save akirillov/afbe61920fbc5b8b86cc to your computer and use it in GitHub Desktop.
QuickSort Example from "Scala by Example"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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