#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string a[1100];
int n;
bool cmp(string s,string t)
{
return s+t<t+s;
}
int main()
{
int i,j,k;
while (cin>>n)
{
for (i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n,cmp);
for (i=0;i<n;i++)
{
cout<<a[i];
if (i!=n-1)cout<<" ";
}
cout<<endl;
}
}
|