How does Python sort a list of sets?

后端 未结 3 819
忘掉有多难
忘掉有多难 2020-12-06 21:59

Python sorts lists of tuples by looking at the elements of the tuples, in order. Since sets are unordered, how does Python sort a list of sets?

Edit: The question an

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 22:06

    Sets are partially ordered, so

    the output of the list.sort() method is undefined for lists of sets.

    https://docs.python.org/3/library/stdtypes.html#set

提交回复
热议问题