title: Parsing, Aggregating & Sorting text file in Python
body: <p>I have the file named "names.txt" having the following contents:</p>
  
  <pre><code>{"1":[1988, "Anil 4"], "2":[2000, "Chris 4"], "3":[1988, "Rahul 1"],
  "4":[2001, "Kechit 3"], "5":[2000, "Phil 3"], "6":[2001, "Ravi 4"],
  "7":[1988, "Ramu 3"], "8":[1988, "Raheem 5"], "9":[1988, "Kranti 2"],
  "10":[2000, "Wayne 1"], "11":[2000, "Javier 2"], "12":[2000, "Juan 2"],
  "13":[2001, "Gaston 2"], "14":[2001, "Diego 5"], "15":[2001, "Fernando 1"]}
  </code></pre>
  
  <p>Problem statement : File "names.txt" contains some student records in the format - </p>
  
  <p><code>{"number": [year of birth, "name rank"]}</code></p>
  
  <p>Parse this file and Segregate them according to year and then sort the names according to rank. First segregation and then sorting.
  Output should be in the format - </p>
  
  <pre><code>{year : [Names of students in sorted order according to rank]}
  </code></pre>
  
  <p>So the expected output is -</p>
  
  <pre><code>{1988:["Rahul 1","Kranti 2","Rama 3","Anil 4","Raheem 5"],
  2000:["Wayne 1","Javier 2","Jaan 2","Phil 3","Chris 4"],
  2001:["Fernando 1","Gaston 2","Kechit 3","Ravi 4","Diego 5"]}
  </code></pre>
  
  <p>First How to store this file content in a dictionary object? Then Grouping by year &amp; then ordering names by rank? How to achieve this in Python?</p>
  
  <p>Thanks..</p>