Garden 🌻

sort_nums()

Return a new list of these integers sorted in ascending order.

Example
sort_nums([3, 1, 2]) //-> [1, 2, 3]
Source Code
public fun sort_nums(items: List<Int>): List<Int> {
  match items.first() {
    None => [],
    Some(pivot) => {
      let rest = items.slice(1, items.len())
      let smaller = rest.filter(fun(x: Int) { x < pivot })
      let larger = rest.filter(fun(x: Int) { x >= pivot })
      sort_nums(smaller).concat([pivot]).concat(sort_nums(larger))
    },
  }
}