Re: [Tutor] sorting lists in dictionary values

2007-08-26 Thread Terry Carroll
On Sun, 26 Aug 2007, Eric Abrahamsen wrote: > I wrote the stupid little script below for practice; it takes a text > file with a list of surnames, and returns a dictionary where the keys > are first letters of the names, and the values are lists of names > grouped under their appropriate fir

Re: [Tutor] sorting lists in dictionary values

2007-08-26 Thread Eric Abrahamsen
Whoa, this made my brain hurt. And I thought I was being clever using a set... I can't say I really understand this yet, but I'm trying. If anyone's following along at home I found this link kind of helpful: http://python.net/crew/mwh/hacks/setdefault.html Thanks a lot for your help, Eric

Re: [Tutor] sorting lists in dictionary values

2007-08-26 Thread Ricardo Aráoz
Eric Abrahamsen wrote: > I wrote the stupid little script below for practice; it takes a text > file with a list of surnames, and returns a dictionary where the keys > are first letters of the names, and the values are lists of names > grouped under their appropriate first-letter key, like so: > >

Re: [Tutor] sorting lists in dictionary values

2007-08-26 Thread Eric Abrahamsen
> From noob to noob : sort sorts in place. I seem to remember it > returns nothing. > > This works: > > In [12]: directoryOut[12]: > {'A': ['Abercrombie', 'Aalberg'], > 'B': ['Barnaby', 'Black', 'Biggles'], > 'D': ['Douglas', 'Dawn', 'Diggle'], > 'G': ['Granger', 'Gossen']} > > In [13]: for key i

[Tutor] sorting lists in dictionary values

2007-08-26 Thread Eric Abrahamsen
I wrote the stupid little script below for practice; it takes a text file with a list of surnames, and returns a dictionary where the keys are first letters of the names, and the values are lists of names grouped under their appropriate first-letter key, like so: {'A': ['Abercrombie'], 'B':