list_0 = [8,11,2,20,3,8,8,50,6]
newlist1 = []
newlist2 = []
newlist3 = []
i = list_0[0]
for l in list_0:
if l < i:
newlist1.append(l) #比8小的一个列表
elif l == i:
newlist2.append(l)#等于8的一个列表
else:
newlist3.append(l)#大于8的一个列表
newlist1.extend(newlist2)
newlist1.extend(newlist3)#列表1扩展往后加就是结果
print(newlist1)
from collections import deque
list_0 = [8,1,2,3,5,10,4,9,8,8,10,12,2,11]
dq = deque([list_0[0]])
for i in range(1,len(list_0)):
l = list_0[i]
if l == list_0[0]:
dq.append(l)
for i in range(1,len(list_0)):
l = list_0[len(list_0)-i]
if l<list_0[0]:
dq.appendleft(l)
for i in range(1,len(list_0)):
l = list_0[i]
if l > list_0[0]:
dq.append(l)
print(list(dq))