# Cloudin云英 面试题 defsort_special_array(a): ifnot a: return a
ls = [] i = 0 j = len(a) - 1 k = 0 if a[0] < a[-1]: ls.append(a[0]) i += 1 else: ls.append(a[-1]) j -= 1
while i <= j: if ls[k] == a[i]: i += 1 continue if ls[k] == a[j]: j -= 1 continue if a[i] < a[j]: ls.append(a[i]) i += 1 k += 1 else: ls.append(a[j]) j -= 1 k += 1