?Does Python have sorting via "Dictionary Order"?
William Dandreta
wjdandreta at worldnet.att.net
Wed Jun 28 20:57:08 EDT 2000
Hi Norman,
If you convert all to upper or lower case before sorting, that will take
care of the letter problem.
If you prepend a '0' to all single digit numbers that will solve the number
comparison problem.
If you don't want to change the sortees, put them in a dictionary with the
keys adjusted as above.
Bill
Norman Shelley wrote in message <395A92D0.65A205B1 at email.sps.mot.com>...
>Does Python have sorting via "Dictionary Order"? This would be a very
>handy addition as an option to list's sort() function.
>
>This is defined by D. Richard Hipp as:
>"The case of alphabetic characters is ignored, except to break ties.
>Thus "B"
>comes before "b" but after "a". Also, integers embedded in the strings
>compare
>in numerical order. In other words, "x10y" comes after "x9y", not
>before it as
>it would when using strcmp().
>
More information about the Python-list
mailing list