n = int(input(""))word = [] for i in range(n): word.append(input("")) word = sorted(word, key=lambda x: (len(x), x)) for i in word: print(i)
13 but i wont hesitate no more no more it cannot wait im yours
i im it no no but more more wait wont yours cannot hesitate
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!