You have a list of n integers and you want the x smallest. For example,
x_smallest([1, 2, 5, 4, 3], 3) should return [1, 2, 3].
x_smallest([1, 2, 5, 4, 3], 3)
[1, 2, 3]
I\'ll v
In scala, and probably other functional languages, a no brainer:
scala> List (1, 3, 6, 4, 5, 1, 2, 9, 4) sortWith ( _<_ ) take 5 res18: List[Int] = List(1, 1, 2, 3, 4)