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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -