A Times of India ranking pipeline stores article scores as positive and negative integers. Rearrange the scores so the result starts with a positive value and alternates between positive and negative values whenever both signs remain available.
Preserve the relative order of positive values and the relative order of negative values. If one sign has more values than the other, append the remaining values of that sign at the end. Return a new array containing every input value exactly once.
Implement rearrange_by_sign(nums), where nums is a non-empty list of integers containing only positive and negative values. Return a list of the same length. The first value must be positive whenever the input contains a positive value.
def rearrange_by_sign(nums):