Python Easy Solution comparator function
The idea is to sort the transactions in the order of the most dip in initial money. We can do that easily by writing a custom comparator.\n\n\nclass Solution:\n
The idea is to sort the transactions in the order of the most dip in initial money. We can do that easily by writing a custom comparator.\n\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        \n        \n        def compare(x, y):            \n\n            if min(-x[0],-x[0] + x[1] - y[0]) < min(-y[0],-y[0] + y[1] - x[0]):\n                return -1\n            if min(-x[0],-x[0] + x[1] - y[0]) == min(-y[0],-y[0] + y[1] - x[0]):\n                if x[0] < y[0]:\n                    return -1\n                else:\n                    return 1\n            else:\n                return 1\n\n        transactions.sort(key = cmp_to_key(compare))\n\t\t\n        temp = 0\n        ans = float("inf")\n \n        for x in transactions:\n            temp = temp - x[0]\n            ans = min(ans,temp)\n            \n            temp = temp + x[1]\n            \n            \n        return -ans\n```
['Python']