def reOrderArray(L): if not L: return L i, N = 0, len(L) while i < N: while i < N and L[i] < 0: i += 1 j = i + 1 while j < N and L[j] > 0: j += 1 if j < N: L[i], L[i+1:j+1] = L[j], L[i:j] else: break return L