Python-sorted()与sort()

时间:2019-07-26 17:57:19

标签: python python-3.x sorting

    Python 3.6.7

    >>> a = [('a',1), ('b', 2), ('c',3), ('d',4)]
    >>> b = [('b',2), ('c', 3), ('a',1)]
    >>>
    >>>
    >>> a.sort() == b.sort()
    True

    >>> a = [('a',1), ('b', 2), ('c',3), ('d',4)]
    >>> b = [('b',2), ('c', 3), ('a',1)]
    >>>
    >>> sorted(a) == sorted(b)
    False
    >>>

我期望sort()返回false。造成这种行为的排序和排序之间有什么区别。

0 个答案:

没有答案