These market distortions affect the prices and thus the salaries in various ways. Teacher shortages show that the wage is not sensitive to the supply and demand for teachers. Do people shop around for price on needed surgeries? Do they even know the price before receiving the surgery? Do they even pay the price of the surgery? (usually paying some subsidized part of a contractually limited price).
Basketball stars show another market distortion, particularly in college basketball. The player salary is not governed by supply and demand, but by the cartel of college sports (though colleges do compete on non-salary benefits they provide...)
You could assert that these factors just inflate or reduce the supply or the demand, but it's not simply "lots of people want but few provide therefore it pays well".
Not many people can play bagpipes, so supply is low. But not many people will pay to hear bagpipes, so demand is low, too. Bagpiping doesn't pay well.
Nearly everyone needs food cooked, so demand is high. But nearly everyone can cook, so supply is high, too. Cooking doesn't pay well.
Not many people can do surgery, so supply is low. Many people need surgery, so demand is high. Surgery pays well.
Supply and demand explains why surgeons make more than teachers, why basketball stars make more than nurses, and why programmers make more than janitors. It isn't about how hard something is or how noble it is. It's just supply and demand.