summaryrefslogblamecommitdiff
path: root/sources/examples/sort1.scala
blob: f2722b23cc4e0ad2439a056d8e91c963d4a628ed (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                         
import scala._;

module sorter {

  def sort(a: List[Int]): List[Int] = {
    val pivot = a at (a.length / 2);
    sort(a.filter(x => x < pivot))
      :::  a.filter(x => x == pivot)
      :::  sort(a.filter(x => x > pivot))
  }

}