排序即可,注意0的映射
d={0:1,1:0,2:0,3:0,4:1,5:0,6:1,7:0,8:2,9:1}
def get_value(n):
value=0
while n!=0:
temp=n%10
value+=d[temp]
n=int(n/10)
return value
#print(get_value(88))
n=int(input())
L=list(map(int,input().split()))
res=[]
for i in range(n):
res.append((L[i],get_value(L[i])))
#print(res)
res.sort(key=lambda x:(x[1],x[0]))
for index,v in enumerate(res):
print(v[0],end=' ')