Real Madrid leads Group D with 12 points from five matches, two points ahead of second-placed Inter Milan, which also qualified for the last 16 after beating Shakhtar Donetsk 2-0.
Sharif, who beat Real Madrid 2-1 in the first match in September, is third with six points and has qualified for the European League. Shakhtar is at the bottom of the group with one point.
David Alaba gave Real Madrid the lead with a free kick that changed direction in the 30th minute, and Toni Kroos strengthened the visitors’ lead at the end of the first half with a shot that hit the bottom of the crossbar and into the goal.
Karim Benzema made the score 3-0 from the edge of the penalty area after a pass from Ferland Mendy in the 55th minute.
Real Madrid goalkeeper Thibaut Courtois saved a low shot from Adama Traore, while the post hit a header from Sebastian Tell.
Sherif goalkeeper Georgios Athanasiades kept a chance from Marco Asensio at the last minute.
Real Madrid will conclude its matches when it hosts Inter on the seventh of December, while Sharif will visit Shakhtar.