Created
October 25, 2011 14:47
-
-
Save Centaur/1312984 to your computer and use it in GitHub Desktop.
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 quicksort[T : Ordering](l: List[T]) : List[T] = l match { | |
case Nil => Nil | |
case x :: xs => | |
val ord = Ordering[T] | |
import ord._ | |
val smaller = quicksort(xs.filter(_<=x)) | |
val bigger = quicksort(xs.filter(_>x)) | |
smaller ++ List(x) ++ bigger | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment