def sort(list: List[Int]): List[Int] = {
list match {
case List() => list
case List(_) => list
case List(_, _*) => {
val pivot = list(list.length/2)
sort(list.filter(x => x < pivot)) ::: list.filter(x => x == pivot) ::: sort(list.filter(x => x > pivot))
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment