Skip to main content
2 of 5
added 98 characters in body

Edited:

src.sort_by { |_0, _1| _0i, _1i = [_0, _1].map(&:to_i); [[_0, _1].include?(nil) ? [_0i, _1i].max : [_0i, _1i].min, _0i, _1i] }
=> [[nil, 1], [1, 2], [2, nil], [nil, 3], [3, nil], [nil, 4], [4, nil], [nil, 5], [5, nil], [nil, 6], [6, 8], [nil, 7], [7, 9], [8, nil], [9, 10]]

The trick is to use min when both are Numeric, max when there's a nil