Bruno Desthuilliers wrote: >> One more thing. What if I want them in reverse chronological order? I >> tried reverse() but that seemed to put them in reverse alphabetical >> order based on the second element of the tuple (not the year). > > Really ? > > >>> lines = [('1995', 'aaa'), ('1997', 'bbb'), ('1995', 'bbb'), > ('1997', 'aaa'), ('1995', 'ccc'), ('1996', 'ccc'), ('1996', 'aaa')] > >>> lines.sort() > >>> lines > [('1995', 'aaa'), ('1995', 'bbb'), ('1995', 'ccc'), ('1996', 'aaa'), > ('1996', 'ccc'), ('1997', 'aaa'), ('1997', 'bbb')] > >>> lines.reverse() > >>> lines > [('1997', 'bbb'), ('1997', 'aaa'), ('1996', 'ccc'), ('1996', 'aaa'), > ('1995', 'ccc'), ('1995', 'bbb'), ('1995', 'aaa')] > >>>
Oh I didn't sort then reverse, I just replaced sort with reverse. Maybe that's why! -- http://mail.python.org/mailman/listinfo/python-list