pypinyin
排序 仅按拼音首字母 排序
安装pypinyin
pip3 install pypinyin
代码
from pypinyin import lazy_pinyin
chars = ['鑫','鹭','榕','柘','珈','骅','孚','迦','瀚','濮','浔','沱','泸','恺','怡','岷','萃','兖']
chars.sort(key=lambda char: lazy_pinyin(char)[0][0])
print([lazy_pinyin(char) for char in chars])
print(chars)
结果
[['cui'], ['fu'], ['hua'], ['han'], ['jia'], ['jia'], ['kai'], ['lu'], ['lu'], ['min'], ['pu'], ['rong'], ['tuo'], ['xin'], ['xun'], ['yi'], ['yan'], ['zhe']]
['萃', '孚', '骅', '瀚', '珈', '迦', '恺', '鹭', '泸', '岷', '濮', '榕', '沱', '鑫', '浔', '怡', '兖', '柘']