Kevin J. McCarthy authored
The secondary sort was looking at (Sort & SORT_REVERSE) instead of (SortAux & SORT_REVERSE), so wasn't even performing the reverse based on the correct flag. Additionally, afterwards, the primary sort was improperly applying a reverse when the secondary sort returned non-zero. Change SORTCODE() to look at SortAux when we are inside a secondary sort. Change AUXSORT() to return the result if the secondary sort returns non-zero. It is ugly to put a return inside the macro, but the check for non-zero needs to be performed inside the AUXSORT if branch. If the secondary sort returns 0, then the primary sort can still compare index and apply a reverse as needed.