Sort highscores in file python programming -


i have game programming, highest score saved down onto file in shall sorted after best score etc. have coded class , way save down score, cannot figure out how sort them after eachother like: ex:

16  9  3 

the final score process!

# display final score. drawboard(mainboard) scores = getscoreofboard(mainboard) 

change

def save_highscore(self, highscore):     highscores = set(self.get_highscores(false))       if highscore in highscores:           return       highscores.add(highscore)       open(self.highscore_file, "w") f:         f.write(" ".join(str(score) score in highscores))  

to

def save_highscore(self, highscore):     highscores = set(self.get_highscores(false))       if highscore in highscores:           return       highscores.add(highscore)       open(self.highscore_file, "w") f:         f.write("\n".join(str(score) score in sorted(highscores, reverse=true))) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -