def previousPermuation(self, num):
        """
        permutation, reverse operation of next permutation
        :param num: a list of integer
        :return: a list of integer
        """
        n = len(num)

        partition = n-2
        while partition >= 0 and num[partition] <= num[partition+1]:
            partition -= 1

        if partition < 0:
            return num[::-1]

        change = n-1
        while change >= 0 and num[partition] >= num[change]:
            change -= 1

        num[partition], num[change] = num[change], num[partition]

        # num = num[:partition+1]+num[n-1:partition:-1]
        num[partition+1:] = reversed(num[partition+1:])  # direct slice assignment
        return num
dataset/ETHPy150Open algorhythms/LintCode/Previous Permuation.py/Solution.previousPermuation/swapped operands of `>=`