Dr Murray Jorgensen ([EMAIL PROTECTED]) wrote:
        > I have some email addresses that I would like to sort in reverse
        > lexicographic order so that addresses from the same domain will be
        > grouped together. How might that be done?

Because he wants addresses from the same domain to be grouped together
(so that foo.bar.ick.ac should be in the same group as zoo.sno.ick.ac),
it is not sufficient to split at the at-sign.

The obvious method is
(1) reverse the strings
(2) sort the reversed strings
(3) reverse the sorted reversed strings

All of this is obvious except reversing the strings.
There's ?rev, which reverses vectors, but no strrev.

Here's a strrev() I knocked together quickly:

strrev <-
function (s) paste(rev(strsplit(s, character(0))[[1]]), collapse="")

If anyone can tell me how to vectorise this, I would be glad of the lesson.

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to