Python 3 || 3 lines, Counter, sort, chain  || T/S: 87% / 77%
\nLet\'s use an example trace to explain the code.\n\nSuppose that nums = [1,2,1,3,2,3,2].\n\n1. First line trace:\n\nctr = Counter([1,2,1,3,2,3,2]).items()\n  
\nLet\'s use an example trace to explain the code.\n\nSuppose that `nums = [1,2,1,3,2,3,2]`.\n\n1. *First line trace*:\n```\nctr = Counter([1,2,1,3,2,3,2]).items()\n    = [(1,2), (2,3), (3,2)]\n```\n2. *Second line trace*:\n```\narr = sorted([(1,2), (2,3), (3,2)], key = lambda x: (x[1], -x[0]))\n    = [(3,2), (1,2), (2,3)]\n```\n3. *Third line trace*:\n```\n      return chain(*[[digit]* cnt for digit,cnt in [(3,2), (1,2), (2,3)]]) \n -->  return chain(* [[3]*2, [1]*2, [2]*3])\n -->  return chain(* [[3,3], [1,1], [2,2,2]])\n -->  return chain(   [3,3], [1,1], [2,2,2])\n -->  return          [3,3, 1,1, 2,2,2]\n```\n_____\nHere\'s the code:\n```\nclass Solution:\n    def frequencySort(self, nums: list[int]) -> list[int]:\n\n        ctr = Counter(nums).items()                         # <-- 1)\n\n        arr = sorted(ctr, key = lambda x: (x[1], -x[0]))    # <-- 2)\n\n        return chain(*[[n]* cnt for n,cnt in arr])          # <-- 3)\n```\n[https://leetcode.com/problems/sort-array-by-increasing-frequency/submissions/1330070571/](https://leetcode.com/problems/sort-array-by-increasing-frequency/submissions/1330070571/)\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.\n\n
['Python', 'Python3']