Hi, the sort_index method returns incorrect results with GCC 13 (the default for Ubuntu 24.04).
Repro script
require "numo/narray"
3.times do
arr = Numo::SFloat.new(1000).rand
indexes = arr.sort_index
result = arr[indexes[0..4]]
p result if result.to_a != result.to_a.sort
end
Output
Numo::SFloat(view)#shape=[5]
[0.000451068, 0.00365162, 0.00525034, 0.00696475, 0.00320271]
Numo::SFloat(view)#shape=[5]
[3.87633e-05, 0.00209275, 0.0235566, 0.00297531, 0.004504]
The issue doesn't occur with GCC 11 on Ubuntu 22.04, or Clang 17 on Mac.