'''实现冒泡排序后,输出关联字典的key标签:ss,通过,list,冒泡排序,key,print From: https://www.cnblogs.com/catfeel/p/17392489.html
通过值得列表,排序后,拿到字典的key,在透过key,可以关联另一个列表
适用场景,比如投票后,要通过数据拿到前三名的名字'''
a={'a':1,'b':2,'c':3,'d':4}
s=[1,3,2,1]
ss=[]
list_k=[]
for i in range(len(s)):
print('iiiiiiiiiiiiiiii')
print(i)
for j in range(len(s)-i-1):
print('jjjjjjjjjjjjjjjjjjjjj')
print(j)
if s[j] < s[j+1] :# 此为判断是否大于后一个数,大于就换(升序判断),如果想是降序,就把">"改成"<"
s[j], s[j+1] = s[j+1], s[j]
print('mmmmmmmm')
print(j)
ss.append(j)
print(ss)
print(s)
print(s[:3])
for i in s[:3]:
print('22222222')
print(i)
for k in a:
if a[k]==i:
print(k)
list_k.append(k)
print(list_k)