I understand there's different ways of storing data in Python but I can't figure what to use for my needs.
I've made a small client/server game, and I want the amount of guesses it took them to be their score. I would then like to write their name (currently the IP address) along with the score into a file as to create a list of high scores. While I can do that perfectly fine, I only want a maximum of 5 scores stored and to be able to sort them so that when I display the high scores and names to the user, the lowest (being the best score) at the top. I'd also like to allow the username to exist more than once.
While it's easy to write the data and read it, I really can't figure out what data type to use, dictionary would make a lot of sense in some cases, but a key can only have one value and the key can only exist once, a list has no relation to other specific values contained within so neither make sense to use, and tuples can't be sorted either it seems.
I was thinking about reading each line into a sperate list and then using the index to compare the score so I could sort them and write it back to the file, but this would be bad on memory in my opinion?
What would be the easiest method to save the name and score together without using some extreme learning curve like SQL?