Reversing a string in formula language

I’m sure you have all done this before me, but I couldn’t find a way to reverse the letters in a string on this forum. So I took the last resort and wrote it myself.

I needed to sort a view column in an address book by the internet domain, taken from the InternetAddress field (obviously the bit to the right of the “@”). But I wanted to order it by the top level first so I could group addresses in the same country together. Reversing the string seemed the easiest way to do it. Anyway, if it helps, here’s my formula where “temp” is the original mail domain string and “temp2” is the same thing reversed:

temp := @If(@Contains(InternetAddress;“@”); @LowerCase(@RightBack(InternetAddress; “@”)); “None”);

temp2 := “”;

@For(n := @Length(temp); n >= 0; n := n - 1; temp2 := temp2 + @Middle(temp;n;1));

temp2