Fix lexicographical sorting (missing if branch)