Try to add your table id here,
select Id,Name,Sex from UserINfo order by ROW_NUMBER() over (PARTITION BY Sex order by Id),Sex asc
(Or) try Group by
select Id,Name,Sex from UserINfo group by Name,Id,Sex order by ROW_NUMBER() over (PARTITION BY Sex order by Id),Sex asc