问题描述:
Write a function to re-arrange the elements of the given array so that all negative elements appear before positive ones.

测试用例:
['assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]', 'assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]', 'assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]']

生成的代码:
def re_arrange_array(arr, n):
    negative = []
    positive = []
    
    for num in arr:
        if num < 0:
            negative.append(num)
        else:
            positive.append(num)
    
    return negative + positive