sort order for strings of digits

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Nov 1 01:30:51 CET 2012


On 31/10/2012 22:24, Ian Kelly wrote:
> On Wed, Oct 31, 2012 at 3:33 PM, Mark Lawrence <breamoreboy at yahoo.co.uk>wrote:
>
>> Nope.  I'm busy porting my own code from 2.7 to 3.3 and cmp seems to be
>> very dead.
>>
>> This doesn't help either.
>>
>> c:\Users\Mark\Cash\Python>**2to3.py
>>
>> Traceback (most recent call last):
>>    File "C:\Python33\Tools\Scripts\**2to3.py", line 3, in <module>
>>      from lib2to3.main import main
>> ImportError: No module named main
>>
>
> Perhaps you have a sys.path conflict?

Correct, now fixed, thanks.

>
> Use functools.cmp_to_key for porting cmp functions.  "sort(x, my_cmp)"
> becomes "sort(x, key=cmp_to_key(my_cmp))"
>
> The cmp builtin is also gone.  If you need it, the suggested replacement
> for "cmp(a, b)" is "(b < a) - (a < b)".

As it's my own small code base I've blown away all references to cmp, 
it's rich comparisons all the way.

>
> Cheers,
> Ian
>

-- 
Cheers.

Mark Lawrence.



More information about the Python-list mailing list