Use a CTE to calculate your averages, then join to that CTE to create an order by
DECLARE @tmp TABLE(studentid INT IDENTITY(1,1), professorid INT, lectureid INT)
INSERT INTO @tmp (professorid, lectureid)
VALUES(101, 401), (101, 402),(101, 402),(101, 402),(101, 402),(101, 402),
(101, 401), (101, 402),
(102, 403), (102, 404),(102, 404),(102, 404),(102, 404),
(103, 405), (104, 406);
select * from @tmp;
with avgStudents as
(
select professorId, count(studentid)/count( distinct lectureid) as average from @tmp group by professorId
)
select t.studentid, av.professorid, t.lectureid, av.average from @tmp t
inner join avgStudents av on av.professorId = t.professorId
order by av.average desc