Python - Elegant Solution - Double Sort
Intuition\nThere are two kinds of transactions: ones where cost > cashback and ones where cost <= cashback. Notice that only the first kind increases the money 
# Intuition\nThere are two kinds of transactions: ones where `cost > cashback` and ones where `cost <= cashback`. Notice that only the first kind increases the money required, while the latter kind reduces it. So intuitively, we need to order all of the first kind before the second. \n\n# Approach\nWe sort transactions twice: once by the cashback, and once by the cost descending. To compute max money required, we iterate through the first sort and include transactions which cost more than they pay back. We then iterate through the second sort and include transactions which pay back more than they cost.\n\n# Complexity\n- Time complexity:\n**O(n log(n)):** Two sorts, two O(n) loops\n- Space complexity:\n**O(n):** We maintain two sorted lists\n\n# Code\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        a = sorted(transactions, key=lambda t: t[1])\n        b = sorted(transactions, key=lambda t: t[0], reverse=True)\n\n        c = 0\n        mx = 0\n        for t in a:\n            if t[0] > t[1]:\n                c += t[0]\n                mx = max(mx, c)\n                c -= t[1]\n        for t in b:\n            if t[0] <= t[1]:\n                c += t[0]\n                mx = max(mx, c)\n                c -= t[1]\n        return mx\n\n```
['Python3']