Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Walter Prins
Hi, On 9 January 2012 12:31, Sarma Tangirala wrote: > Given a nested list, how do I sort the uppermost list based on one key and > when a special condition occurs a sort on another key should be performed? > > For example, [[1,2], [2, 2], [3, 2], [4, 0]] would be sorted, in my example > as, [[4,

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Sarma Tangirala
On 9 January 2012 18:26, Steven D'Aprano wrote: > Sarma Tangirala wrote: > >> Hi list, >> >> I was banging my head about a pythonic way of doing the following, >> >> Given a nested list, how do I sort the uppermost list based on one key and >> when a special condition occurs a sort on another key

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Peter Otten
Sarma Tangirala wrote: > I was banging my head about a pythonic way of doing the following, > > Given a nested list, how do I sort the uppermost list based on one key and > when a special condition occurs a sort on another key should be performed? > > For example, [[1,2], [2, 2], [3, 2], [4, 0]]

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Steven D'Aprano
Sarma Tangirala wrote: Hi list, I was banging my head about a pythonic way of doing the following, Given a nested list, how do I sort the uppermost list based on one key and when a special condition occurs a sort on another key should be performed? For example, [[1,2], [2, 2], [3, 2], [4, 0]] w

[Tutor] Sorting Nested Lists

2012-01-09 Thread Sarma Tangirala
Hi list, I was banging my head about a pythonic way of doing the following, Given a nested list, how do I sort the uppermost list based on one key and when a special condition occurs a sort on another key should be performed? For example, [[1,2], [2, 2], [3, 2], [4, 0]] would be sorted, in my ex