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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -