Python: dictionary sorting by key problem
I don't really understand what's wrong with my code and I can't think of anything because the output is messed up in a pretty strange way. I'm not an expert, started python & programming like 3 weeks ago code: https://pastebin.com/isq80i0K text: https://pastebin.com/4RdauWBC file(output): https://pastebin.com/qnuNnyLj This code should read the third number from text in each line, which is an identifier for a person and then it stores it in a dictionary to count how often a person shows up(value). Then I tried to sort this dictionary by value with a break after each line, but the sorting is kinda messed up, as you can see. Number 1 is good, then suddenly 10 comes and goes until 18, then randomly number 2, and it goes on. I don't understand what I messed up or why it is like that. For anyone wondering, some words in my code (like "athaladas", "ajto", "be/ki") are Hungarian.