Revamped checks for sortDirection
Merge pull request #186 from renotoaster/harri-14360

#14360: Revamped checks for sortDirection