#14360: Revamped checks for sortDirection