字符排序
无技术含量,纯为复制粘贴方便👍
s=''
ls=[]
num=[]
for i in s:
pos=-1
for j in range(len(ls)):
if ls[j]==i:
pos=j
break
if pos==-1:
ls.append(i)
num.append(1)
else:
num[pos]+=1
for i in range(len(ls)):
for j in range(len(ls)-i-1):
if num[j]<num[j+1]:
num[j],num[j+1]=num[j+1],num[j]
ls[j],ls[j+1]=ls[j+1],ls[j]
for i in ls:
print(i,end='')