题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
while True: try: n = int(input()) sortDict = {} for i in range(n): strvalue = input() keyvalue = strvalue[0] if keyvalue in sortDict: sortDict[keyvalue].append(strvalue) else: sortDict[keyvalue] = [] sortDict[keyvalue].append(strvalue) for i in range(len(sortDict)): minKey = min(sortDict.keys()) minValue = sortDict.pop(minKey) # 对列表的值进行排序 minValue.sort() print('\n'.join(minValue)) except: break