fork download
  1. n = int(input(""))
  2. word = []
  3.  
  4. for i in range(n):
  5. word.append(input(""))
  6.  
  7. word = sorted(word, key=lambda x: (len(x), x))
  8.  
  9. for i in word:
  10. print(i)
  11.  
  12.  
Success #stdin #stdout 0.03s 9856KB
stdin
13
but
i
wont
hesitate
no
more
no
more
it
cannot
wait
im
yours
stdout
i
im
it
no
no
but
more
more
wait
wont
yours
cannot
hesitate