fork download
  1. import sys
  2. from operator import itemgetter
  3.  
  4. k = 0
  5. song_list = []
  6. firstline = True
  7. # Get all lines read in split and in an array
  8. for line in sys.stdin:
  9. if firstline == True:
  10. k = int(line)
  11. firstline = False
  12. elif len(line) <= 2:
  13. pass
  14. else:
  15. string = line[:-7]
  16. number = line[-6:-1]
  17. temp_list = (string, int(number))
  18. song_list.append(temp_list)
  19.  
  20. # sort based on the number of each list
  21.  
  22. sorted(song_list, key=itemgetter(1,0))
  23.  
  24. for i in range(0, k):
  25. print(song_list[i])
Success #stdin #stdout 0.01s 27704KB
stdin
3
&
Pink Frost&Phillipps, Martin&234933
Se quel guerrier io fossi&Puccini, Giacomo&297539
Non piu andrai&Mozart&234933
M'appari tutt'amor&Flotow, F&252905
stdout
('Pink Frost&Phillipps, Martin&', 34933)
('Se quel guerrier io fossi&Puccini, Giacomo&', 97539)
('Non piu andrai&Mozart&', 34933)