blob: 0168170ea20ab1aed3f61a9ca052f52df59ec7bb [file] [log] [blame]
package sample
class Sorting {
def sort(xs: Array[Int]): Array[Int] =
if (xs.length <= 1) xs
else {
val pivot = xs(xs.length / 2)
Array.concat(
sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <)))
}
}