This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
string a[N];
bool cmp(const string &a, const string &b) {
//自定义排序函数,这一步非常巧妙,假设a=321,b=32;a+b=32132,b+a=32321
// 这样下面sort排下来就是32>321避免出现32132>32321的情况
return a + b > b + a;
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; i++)cout << a[i];
return 0;