Created
April 27, 2012 06:31
-
-
Save notyy/2506584 to your computer and use it in GitHub Desktop.
quicksort in scala
This file contains hidden or 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 qs[T <% Ordered[T]](l: List[T]): List[T] = l match { | |
case Nil => Nil | |
case (x :: xs) => { | |
val (less,greater) = xs partition (_ <= x) | |
qs(less) ++ (x :: qs(greater)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment