With the exception of the fact that I did mean $sorttok, rather than $sort (which was a typo)...the code I posted works for me, and that's what I was basing it on when I posted it.