Solution by using Priority Queue and Comparator in C++✅✅
\n\n\n#define pii pair<int, int>\n\nclass MyComp\n{\npublic:\n    bool operator()(pii const &p1, pii p2)\n    {\n        if (p1.first == p2.first)\n        {\n 
\n```\n\n#define pii pair<int, int>\n\nclass MyComp\n{\npublic:\n    bool operator()(pii const &p1, pii p2)\n    {\n        if (p1.first == p2.first)\n        {\n            return p1.second <p2.second;\n        }\n        return p1.first >p2.first;\n    }\n};\n\nclass Solution\n{\npublic:\n    vector<int> frequencySort(vector<int> &nums)\n    {\n        vector<int> ans;\n        priority_queue<pii, vector<pii>, MyComp> pq;\n\n        unordered_map<int, int> mp;\n        for (int n : nums)\n            mp[n]++;\n\n        for (auto it : mp)\n            pq.push({it.second, it.first});\n\n        while (not pq.empty())\n        {\n            int freq = pq.top().first;\n            int n = pq.top().second;\n\n            pq.pop();\n            while (freq--)\n            {\n                ans.push_back(n);\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C']