And if you had read the initial post you'd see that the original poster wanted something similar to what Ricky posted.
Short, effective.

Edit: It wont work anyway, invalid use of parentheses.
Code:
if ($gettok(%sortvar, %counter, 32) == $gettok(%sortvar, $calc( %counter + 1 ), 32)[color:red])[/color] {


I wont load it in and test for more errors, it was just something I spotted off hand.