Re: [Python-ideas] Multiple level sorting in python where the order of some levels may or may not be reversed

2016-10-21 Thread Sven R. Kunze
On 17.10.2016 23:53, Paul Moore wrote: On 17 October 2016 at 22:28, Mark Lawrence via Python-ideas wrote: How about changing https://wiki.python.org/moin/HowTo/Sorting ? Good point. Better still, https://docs.python.org/3.6/howto/sorting.html Don't know what the

Re: [Python-ideas] Multiple level sorting in python where the order of some levels may or may not be reversed

2016-10-17 Thread Tim Peters
[Sven R. Kunze ] > Indeed. I also didn't know about that detail of reversing. :) Amazing. (Also > welcome to the list, Alireza.) It follows from what the docs say, although I'd agree it may be helpful if the docs explicitly spelled out this consequence (that reverse=True also

Re: [Python-ideas] Multiple level sorting in python where the order of some levels may or may not be reversed

2016-10-17 Thread Paul Moore
On 17 October 2016 at 22:28, Mark Lawrence via Python-ideas wrote: > How about changing https://wiki.python.org/moin/HowTo/Sorting ? Good point. Better still, https://docs.python.org/3.6/howto/sorting.html Paul ___

Re: [Python-ideas] Multiple level sorting in python where the order of some levels may or may not be reversed

2016-10-16 Thread Tim Peters
[Alireza Rafiei ] > I have a list called count_list which contains tuples like below: > > > [('bridge', 2), ('fair', 1), ('lady', 1), ('is', 2), ('down', 4), > > ('london', 2), ('falling', 4), ('my', 1)] > > > I want to sort it based on the second parameter in

Re: [Python-ideas] Multiple level sorting in python where the order of some levels may or may not be reversed

2016-10-15 Thread Chris Angelico
On Sun, Oct 16, 2016 at 3:29 PM, Alireza Rafiei wrote: > What I ended up doing is: > >> count_list = sorted(count_list, >> key=lambda x: (x[1], map(lambda x: -x, map(ord, >> x[0]))), >> reverse=True) > > > which works. Now my