On 22 Jul 2000, at 14:46, Mika Tuupola wrote:
> On Wed, 12 Jul 2000, Michael Brach wrote:
>
> > Managing a few lists for professional associations, I sometines have to
> > sort email addresses. It is very useful
> > - to do this alphabetically from the end of the address
>
> Plain unix sort can also do this. If you ment sorting
> by domain this can be done with something like (assuming
> addresses are one address per line):
>
> sort -t@ -k2 addressfile
>
> This spits the addressfile sorted by domain to stdout.
No, actually... unless I"m missing something subtle in the sort args, the
list is sorted by *host*, and so all the mail.* hosts are lumped
together, regardless of domain, etc. rather than really sorting 'by
domain' which usually means dot-segment-right-to-left, so all the '.au's
are at the top, the '.edu's toward the middle and the '.za's at the end,
all of the *.hp.com and *.microsoft.com addresses sorted together, etc.
It isn't all that easy to do. In perl, the sort of thing you'd need
would be:
my @addrs ; # Has mailing addresses, one per line
my @keys = map [ join("\0",
reverse(split /\./, (split /\@/)[1])),
], @addrs ;
my @sorted = map $_->[1], sort { $a->[0] cmp $b->[0]} @keys ;
It woudln't be hard to add the email address, itself, to the sort key [so
that all of the email addresses within a single host would be in alph
order]
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
mailto:[EMAIL PROTECTED] Pearisburg, VA
--> Too many people, too few sheep <--