Wrong answer because of ordering

#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
string group[n];
map<string,vector> anagram;
for(int i=0;i<n;i++){
cin>>group[i];
string t = group[i];
sort(t.begin(),t.end());
anagram[t].push_back(group[i]);
}
for(auto it : anagram){
vector vec = it.second;
for(int i=0;i<vec.size();i++){
cout<<vec[i]<<" ";
}
cout<<endl;
}
return 0;
}

what ordering am i missing?

Hey @varss777 submit it on leetcode. If it gets accepted then your logic is right. Cause in question it’s mentioned that no order matters but at the backend site, it has fixed output format. So submit it on leetcode to get confirmation.

thanks, it got submitted

So your logic was correct it’s just fault on back end site.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.