How to sort list

bearophileHUGS at bearophileHUGS at
Tue Nov 21 20:46:46 CET 2006

> Emails=['a at','a at','b at','c at',....]
> after sorting I would like to have
> Emails=['a at','b at','a at','c at',....]

This problem isn't easy to solve in the general way, this is a first

emails = ['a at','a at','b at','c at']

print sorted(emails, key=lambda em: em.split("@")[::-1])


More information about the Python-list mailing list