On Wed, 25 Oct 2023 at 13:02, Mike H via Python-list
wrote:
> Is it possible to use lambda expression instead of defining a `Key` class?
> Something like `sorted(my_list, key = lambda x, y: x+y > y+x)`?
Look up functools.cmp_to_key.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-lis
On Saturday, October 15, 2016 at 12:27:42 AM UTC-7, Peter Otten wrote:
> 38016...@gmail.com wrote:
>
> > nums=['3','30','34','32','9','5']
> > I need to sort the list in order to get the largest number string:
> > '953433230'
> >
> > nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
> >
在 2016年10月14日星期五 UTC-4下午7:35:08,38016...@gmail.com写道:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string: '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank you
!I learn mo
38016226...@gmail.com wrote:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string:
> '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank you
While cmp_to_key is neat doing it by
On Saturday, October 15, 2016 at 12:53:48 AM UTC+1, sohca...@gmail.com wrote:
> On Friday, October 14, 2016 at 4:35:08 PM UTC-7, 38016...@gmail.com wrote:
> > nums=['3','30','34','32','9','5']
> > I need to sort the list in order to get the largest number string:
> > '953433230'
> >
> > nums.sort
On Friday, October 14, 2016 at 7:49:33 PM UTC-4, Robin Koch wrote:
> Am 15.10.2016 um 01:33 schrieb 38016226...@gmail.com:
> > nums=['3','30','34','32','9','5']
> > I need to sort the list in order to get the largest number string:
> > '953433230'
> >
> > nums.sort(cmp=lambda a,b: cmp(a+b, b+a), r
38016226...@gmail.com writes:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string: '953433230'
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
For demonstration, I'll re-write this such that the names and output
make more sense::
$
On Friday, October 14, 2016 at 4:35:08 PM UTC-7, 38016...@gmail.com wrote:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string: '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank
Am 15.10.2016 um 01:33 schrieb 38016226...@gmail.com:
nums=['3','30','34','32','9','5']
I need to sort the list in order to get the largest number string: '953433230'
nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
But how to do this in python 3?
https://docs.python.org/3/library/funct
nums=['3','30','34','32','9','5']
I need to sort the list in order to get the largest number string: '953433230'
nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
But how to do this in python 3?
Thank you
--
https://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo