Skip to content

Instantly share code, notes, and snippets.

@yannick-cw
Created June 2, 2020 07:41
Show Gist options
  • Save yannick-cw/9a8ab879c648c6e5efb60559d2b13e61 to your computer and use it in GitHub Desktop.
Save yannick-cw/9a8ab879c648c6e5efb60559d2b13e61 to your computer and use it in GitHub Desktop.
import Ordering.Implicits._
def quicksort[A: Ordering](l: List[A]): List[A] = l match {
case x :: (xs @ (y :: z)) =>
val (smallerEq, greater) = xs.partition(_ <= x)
quicksort(smallerEq) ++ List(x) ++ quicksort(greater)
case base => base
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment