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

分类:列表、排序

知识点:

  1. 字典序排序    sorted(my_list)

题目来自【牛客】

图片


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 软件工程小施同学 

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-02-15 08:36:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-15 08:36:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-15 08:36:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-15 08:36:03       18 阅读

热门阅读

  1. 人类知识的分类

    2024-02-15 08:36:03       26 阅读
  2. Vue中@change、@input和@blur的区别及@keyup介绍

    2024-02-15 08:36:03       34 阅读
  3. 【软件设计模式之命令模式】

    2024-02-15 08:36:03       23 阅读
  4. 【数据结构】单调栈

    2024-02-15 08:36:03       41 阅读
  5. c++STL系列——(八)multiset

    2024-02-15 08:36:03       27 阅读
  6. Leetcode 392 判断子序列

    2024-02-15 08:36:03       21 阅读
  7. Windows安装DeepSpeed

    2024-02-15 08:36:03       37 阅读
  8. 什么是系统工程(字幕)27

    2024-02-15 08:36:03       23 阅读
  9. 2024.2.14作业

    2024-02-15 08:36:03       38 阅读