Sorting strings.

Greg Jorgensen gregj at pobox.com
Thu Feb 8 02:54:15 EST 2001


In article <4a1yt93frj.fsf at kern.srcf.societies.cam.ac.uk>,
  Gaute B Strokkenes <gs234 at cam.ac.uk> wrote:
> ...
> The problem with this approach is that string comparison doesn't quite
> have the behaviour that I would like.  For instance, I'd like numbers
> to come after letters, and I'd like to be case insensitive.  Is there
> a reasonably clean way to do this?

You can write a function to compare strings according to your rules:
ignore case, make the digits greater than letters, and (maybe) ignore
punctuation and anything else not alphanumeric. Then use that function
to compare author, title, etc. rather than <, ==, >.

--
Greg Jorgensen
Portland, Oregon, USA
gregj at pobox.com


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list