*python code* problem/s with .txt file and tuples + dictionaries
<p>I am writing this game, and having trouble coding my high scores list.</p>

<p>The high score table consists of a .txt file where the Name, Score is listed in that order, each on a new line right now for testing it has.</p>

<pre><code>Matthew, 13
Luke, 6
John, 3
</code></pre>

<p>my code to record the score is:</p>

<pre><code> print "You got it!\nWell done", NAME,",You guessed it in", count, "guesses."
 save = raw_input("\nWould you like to save your score? (Y)es or (N)o: ")
 save = save.upper()
 if save == "Y":
     inFile = open("scores.txt", 'a')
     inFile.write("\n" + NAME + ", " + str(count))
     inFile.close()
     count = -1
 if save == "N":
     count = -1
</code></pre>

<p>and my code to show the score is:</p>

<pre><code>def showScores():
    inFile = open("scores.txt", 'r')
    scorelist = {}
    for line in inFile:
        line = line.strip()
        parts = [p.strip() for p in line.split(",")]
        scorelist[parts[0]] = (parts[1])
    players = scorelist.keys()
    players.sort()
    print "High Scores:"
    for person in players:
        print person, scorelist[person]
        inFile.close()
</code></pre>

<p>I don't know how to sort it right, right now it sorts according to Alphabetical order, But I'd like to sort it in numerical order from smallest to biggest, but still keep the format of NAME, count.</p>

<p>Also every time, I try to save a new high score with the same Name it stores it...</p>

<p>in .txt</p>

<pre><code>Matthew, 13
Luke, 6
John, 3
Mark, 8
Mark, 1
</code></pre>

<p>but only shows the most recent score from the same name,</p>

<p>In python shell</p>

<pre><code>High Scores:
John 3
Luke 6
Mark 1
Matthew 13
</code></pre>

<p>Or only shows one instance of the same item, I guess.. does anyone know how to fix that too?</p>

<p>Thanks in advance</p>
