2413: 【例71.2】 01串排序

Memory Limit:64 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

将 $01$ 串首先按长度排序,长度相同时,按 $1$的个数多少进行排序,$1$的个数相同时再按 ASCII 码值排序(字典序)。

Input

第一行输入一个整数 $n$ ($1≤n≤100$),表示字符串的个数。n输入数据中含有一些 $01$ 串,$01$ 串的长度不大于 $256$个字符。

Output

重新排列 $01$ 串的顺序,使得串按基本描述的方式排序,然后依次输出。

Sample Input Copy

6
10011111
00001101
1010101
1
0
1100

Sample Output Copy

0
1
1100
1010101
00001101
10011111

Source/Category