LPS-47551 Validate that a sort can be null

Hey Andrew, can you review these changes related to the search stuff? You worked on multiple sorts here (LPS-51569) and I'd like to be sure I not work your code. cc/ @juliocamarero @ligasm