Python Easy solution (beats 100% time and 100% memory)
A dictionary to have the list orders the for the particular table, Orders are the words as they are, add all the items into a set. Once complete traversal done,
A dictionary to have the list orders the for the particular table, Orders are the words as they are, add all the items into a set. Once complete traversal done, Sort the set and get the list and get the index of every item into another dictionary. Finally traverse the table dictionary in sorted form, get the index number of each order and increament the count in the return value.\n```\nclass Solution:\n    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:\n        table = defaultdict(list)\n        items, itemNo = set(), {}\n        retVal = []\n        for order in orders:\n            if order[2] not in items:\n                items.add(order[2])\n            table[order[1]].append(order[2])\n        retVal.append([\'Table\'])\n        for i,item in enumerate(sorted(items)):\n            itemNo[item] = i+1\n            retVal[0].append(item)\n        for k in sorted(table.keys(), key=lambda x: int(x)):\n            retVal.append(["0"] * (len(items)+1))\n            retVal[-1][0] = k\n            for val in table[k]:\n                retVal[-1][itemNo[val]] = str(int(retVal[-1][itemNo[val]]) + 1)\n        return retVal\n```
[]