logic fixes for two field sort