Taxation, Sorting and Redistribution: Theory and Evidence