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 you

You don't need a lambda in this case.

Sort the strings in reverse order:

Create a string:
biggestNum = ''.join(nums)

Or in a single line, which doesn't change the original value of nums:
biggestNum = ''.join(sorted(nums, reverse=True))


Reply via email to