华为机考入门python3--(14)牛客14-字符串排序

分类:列表、排序

知识点:

  1. 字典序排序 sorted(my_list)

题目来自【牛客】

python 复制代码
def sort_strings_by_lex_order(strings):  
    # 使用内置的sorted函数进行排序,默认是按照字典序排序  
    sorted_strings = sorted(strings)  
    # 返回排序后的字符串列表  
    return sorted_strings  


n = int(input().strip())

strings = []
for i in range(n):
    strings.append(input().strip())

sorted_strings = sort_strings_by_lex_order(strings)  

# 输出结果  
for s in sorted_strings:  
    print(s)

by 软件工程小施同学

相关推荐
zyl7651 天前
FlashAttention 详解:从 GPU 硬件、普通 Attention 到分块计算与 Online Softmax
算法
爱读书的小胖1 天前
LeetCode 122:买卖股票的最佳时机 II(C)解题分析
算法
结局无敌1 天前
React Native for OpenHarmony 实战:三方库 react-native-modal-dialog 的鸿蒙化适配指南
深度学习·算法·react native·react.js·harmonyos
OPEN-F1 天前
ROS2系列教程:上位机建图与导航(原理综合)
算法·机器人
weixin_307779131 天前
C++代码实现MATLAB中的fitrtree函数功能
开发语言·c++·算法·matlab
tomwang03221 天前
路径优化建模、优化算法分类及工程化小结
算法·数学建模·分类
小羊没烦恼!1 天前
Ajax与JSON的一些总结
android·java·前端·数据库·mysql·算法·okhttp
2501_926978331 天前
人机通信协议--人和机器之间的交互想象
人工智能·经验分享·算法·ai写作
行者全栈架构师1 天前
【鸿蒙心迹】互动卡片全链路——把核心功能放到桌面(FormKit 实战)(HarmonyOS 7.x)
前端·算法·架构
hunterandroid1 天前
HarmonyOS 长列表滚动性能优化:预渲染、离屏缓存与 GPU 合成策略
华为·前端框架