Just do a truncated selection sort?
In QB64PE BASIC (just because we can) B-) ...
For i = 1 to m
For j = i to Ubound(array)
If array(j) < array(i) Then Swap array(j), array(i)
Next j
Next i
You now have the smallest m items from array() in the first m positions.
I just implemented this in QB64PE (again, because why not?) to find the 10 smallest elements from an array of 27,100 integers, and it took just on 1 microsecond on an M3Max MBP.