how to compare two strings?
Remco Gerlich
scarblac at pino.selwerd.nl
Tue Feb 12 08:47:10 EST 2002
More information about the Python-list mailing list
Tue Feb 12 08:47:10 EST 2002
- Previous message (by thread): how to compare two strings?
- Next message (by thread): how to compare two strings?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Paul Rubin <phr-n2002a at nightsong.com> wrote in comp.lang.python: > Is there any built-in function in Python for comparing two strings > alphabetically? Something suitable for passing as the optional > comparison function for the list "sort" method. I could code up > something like > > def scmp(a,b): > if a<b: return -1 > if b<a: return 1 > return 0 > > but it's pretty ugly to need to do that. I've looked in the docs but > don't see any obvious counterpart to perl's lozenge (<=>) operator. > Is there one? Uhm. scmp() is the same as the builtin cmp(), as far as I can see. Which means that this is the default action of sort(), no need to give it any function. -- Remco Gerlich
- Previous message (by thread): how to compare two strings?
- Next message (by thread): how to compare two strings?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list