need help using sort

Hi there,
I kinda know regular expressions, but I don't think they apply here. I have a file with URLs in the form:
http://username:thepassword@www.example.com

All the lines are all mixed up. How can I use the sort program to sort them starting at the www part? Basically, the URL split point is at the @ sign; anything to the left I don't care about, but after the @ I want to sort.

Example:
Sorting this:
http://nombre:abc123@www.aaaaa.com
http://zuser:dddd@bbb.com

Results in this:
http://zuser:dddd@bbb.com
http://nombre:abc123@www.aaaaa.com

Thanks in advance. :slight_smile:

This may work. If not, play around with the sort options

sort -t@ file -k 2

or if you want more control, here's a Python alternative

#!/usr/bin/python
store = {}
for line in open("file"):
        left,right = line.split("@")
        store = right
a = sorted([ (value, key) for key, value in store.items() ] )
for val,key in a:
        print key + "@" + value

Thanks,

sort -t@ file -k 2

That worked.