使用自带的全排列函数,去重后使用sorted进行字典序排序

from itertools import permutations
 
class Solution:
    def permuteUnique(self , num: List[int]) -> List[List[int]]:
        # write code here
        return sorted(list(set(permutations(num))))