>>> names = ["john", "hack", "blank"]
>>> abc = sorted(names)
>>> abc
['blank', 'hack', 'john']
>>> abcd = sorted(names, reverse=True)
>>> abcd
['john', 'hack', 'blank']
默认是reverse=False 升序
博客提及默认情况下 reverse 为 False 代表升序。在信息技术中,排序操作常见于多种编程语言和应用场景,如 Python、Java 等语言都有排序相关功能。
>>> names = ["john", "hack", "blank"]
>>> abc = sorted(names)
>>> abc
['blank', 'hack', 'john']
>>> abcd = sorted(names, reverse=True)
>>> abcd
['john', 'hack', 'blank']
默认是reverse=False 升序
1万+
999
2069

被折叠的 条评论
为什么被折叠?