exact: fix the sort order

Oops, last minute 'let me just invert this if condition' totally broke
sort order.  Add a unit test to prevent this from happening again.