Sort by domain name?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Oct 2 11:51:52 EDT 2006


Tim Chase:
> to give you a sorting function.  It assumes http rather than
> having mixed url-types, such as ftp or mailto.  They're easy
> enough to strip off as well, but putting them back on becomes a
> little more exercise.

With a modern Python you don't need to do all that work, you can do:

sorted(urls, key=cleaner)

Where cleaner is a function the finds the important part of a string of
the ones you have to sort.

Bye,
bearophile




More information about the Python-list mailing list