List of lists value in dictionary?
<p>Input file 'test.txt':</p>

<pre><code>a 2012 fff

b 2011 ttt

a 2011 fff

b 2012 sss

a 2011 vvv
</code></pre>

<p>I have determined the following code to populate dictionary and sort values:</p>

<pre><code>from collections import defaultdict
res = defaultdict(list)
with open('test.txt','r') as file:
    for line in file:
        field0, field1, field2 = line.split()
        res[field0] += [field1, field2]

for i in res.keys():
    print i, sorted(res[i], key=lambda x: x[0])
</code></pre>

<p>However, this yields "a [2011, 2011, 2012, fff, fff, vvv]" and I want output to be in the exact same format as the input (but sorted):</p>

<pre><code>a 2011 fff

a 2011 vvv

a 2012 fff
</code></pre>

<p>I can't just use sort on the original input since I will be referencing multiple times and need to store in memory. Should value for each line be stored in a list (ie. dictionary value is list of lists)?</p>
