函数sort进行排序,在本地进行排序,不返回副本
函数sorted进行排序,返回副本,原始输入不变

---------------------------------sort----------------------------------------
>>> help(list.sort)
Help on method_descriptor:

sort(...)
    L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
    cmp(x, y) -> -1, 0, 1
--------------------------------sorted---------------------------------------
>>> help(sorted)
Help on built-in function sorted in module __builtin__:

sorted(...)
    sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list

-----------------------------------------------------------------------------

https://blog.csdn.net/qdPython/article/details/118759865

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-06-08
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-03
  • 2021-08-05
  • 2022-12-23
  • 2022-02-25
  • 2022-01-05
  • 2022-12-23
相关资源
相似解决方案