3 ms·
I still like the pattern matching version, better. It's more concise, and I can actually follow it easier. (but my brain is weird): def qsort[T <% Ordered[T]
by warfangle 16y ago
I still like the pattern matching version, better. It's more concise, and I can actually follow it easier. (but my brain is weird):
def qsort[T <% Ordered[T]](list:List[T]):List[T] = {
list match {
case Nil => Nil
case x::xs =>
val (before,after) = xs partition (_ < x)
qsort(before) ++ (x :: qsort(after))
}
}