方法1: 简单数组拼接
def order(array):
array1 = []
array2 = []
for index,value in enumerate(array):
if index % 2 == 1:
array1.append(value)
else:
array2.append(value)
return array2 + array1
方法二: 用函数的组合 https://www.runoob.com/python/python-func-sorted.html
def reOrderArray( array):
# write code here
return sorted(array, key= lambda x:x%2, reverse=True)
print(reOrderArray([2,5,4,3,6]))