Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. Bob: 0 /10
  2. Bob: 1 /10
  3. Jane: 9 /10
  4. Drake: 5 /10
  5. Dan: 4 /10
  6. Josh: 1 /10
  7. Dan: 5 /10
  8.  
  9. dataList = []
  10. with open(sourceFile,'r') as dataFile:
  11. for line in dataFile:
  12. dataList.append (line.split(":"))
  13. dataList.sort(key = lambda x : x[1],reverse = True)
  14. final = [":".join(line) for line in dataList]
  15. with open (newFile,'w') as finalFile:
  16. for line in final:
  17. finalFile.write(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement