Sort_nil Apr 4th, 2019 5:12 pm 1 2 3 4 5 s = [1, 0, 2, nil, 3] # sort index p s.map{|i|i == nil ? 1.0/0.0 : i}.map.with_index.sort.map(&:last)