#include<iostream> #include<string> #include<algorithm> using namespace std; bool comp(string rhs, string lhs){ if (rhs.size() < lhs.size()){ return true; } else if (rhs.size() == lhs.size() && rhs < lhs){ return true; } else{ return false; } } int main(){ int n; while (scanf("%d", &n) != EOF){ string arr[100]; for (int i = 0; i < n; i++){ cin >> arr[i]; } sort(arr, arr + n,comp); for (int i = 0; i < n; i++){ cout << arr[i] << endl; } } }