1.设立一个需要排序的表
2.使用for循环将列表里的汉字转换为拼音
3.将拼音的首字母排序(按照英文字母的顺序)
4.for循环将排序好的文字添加到列表里
5.print()输出
代码:
fromxpinyinimportpinyindefmy _ soft (word list ) : pin=Pinyin ) ) temp=[ ] foriteminwordlist 3360 temp.append ) pin forIinrange(len(temp ) ) : result.append (temp [ I ] returnresultprint () ) ) 65
排序前:华为、小米、苹果、三星排序后:华为、苹果、三星、小米