Python Solution (Dictionary + Sort)
```\nclass Solution:\n    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:\n        d={i[1]:{} for i in orders} \n        names=[i[2] for i i
```\nclass Solution:\n    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:\n        d={i[1]:{} for i in orders} \n        names=[i[2] for i in orders]\n        for i in orders:\n            temp=d[i[1]]\n            temp[i[2]]=temp.get(i[2],0)+1\n        for i in d:\n            temp=d[i]\n            for j in names:\n                if j not in temp:\n                    temp[j]=0                \n            d[i]={k:v for k,v in sorted(temp.items(),key=lambda x:x[0])}\n        d={k:v for k,v in sorted(d.items(),key=lambda x:int(x[0]))}\n        ans=[["Table"]+sorted(set(names))]\n        for i in d:\n            res=[i]\n            temp=d[i]\n            for j in temp:\n                res.append(str(temp[j]))\n            ans.append(res)\n        return ans\n
[]