Fix sort key creation (bug introduced by previous commit)