fork download
  1. # using stdin in this online platform
  2. from sys import stdin
  3. fileReading = stdin
  4. # fileReading = open("leaderboard.txt","r")
  5. # back to the original code:
  6. lines = fileReading.read()
  7. fileReading.close()
  8. lines = lines.split("\n")
  9. for line in lines:
  10. print(line)
  11.  
  12. def bubbleSort(arr):
  13. n = len(arr)
  14.  
  15. for i in range(n-1):
  16.  
  17. for j in range(0, n-i-1):
  18.  
  19.  
  20. if arr[j] > arr[j+1] :
  21. arr[j], arr[j+1] = arr[j+1], arr[j]
  22.  
  23. # Driver code to test above
  24. arr = lines
  25.  
  26. bubbleSort(arr)
  27.  
  28. print ("Sorted array is:")
  29. for i in range(len(arr)):
  30. print ("%s" %arr[i])
Success #stdin #stdout 0.02s 9184KB
stdin
76: Daniel
36: Gabriel
30: Perry
92: Avi
28: Yehuda
46: Jeremy
54: Mordechai
96: Paul
80: Pauline
72: Fran
stdout
76: Daniel
36: Gabriel
30: Perry
92: Avi
28: Yehuda
46: Jeremy
54: Mordechai
96: Paul
80: Pauline
72: Fran
Sorted array is:
28: Yehuda
30: Perry
36: Gabriel
46: Jeremy
54: Mordechai
72: Fran
76: Daniel
80: Pauline
92: Avi
96: Paul