Spatial Externalities and Wage Distribution: the Role of Sorting