给定一个数组 按重复次数 降序排列输出 数组非空且为正整数【杭州多测师】【杭州多测师_王sir】
a=[1,1,1,2,2,2,2,6,5,5,5,5] num=[] for i in a: s = a.count(i) num.append(s) num1 = sorted(num,reverse=True) num2=list(set(num1)) num2.sort(key=num1.index) num3=[] for x in num2: for i in a: if x ==a.count(i): num3.append(i) else: pass num4=[] for j in num3: if j not in num4: num4.append(j) print(num4)