This paper presents a model of task assignment and worker matching to explore how the distributions of labor endowments within countries influence aggregate productivity and international trade patterns. Higher moments of the skill distribution have complex relationships with the organization of the labor force. First, labor endowments skewed toward high abilities exhibit positive assortment of workers across tasks, while countries with distributions of ability skewed towards low abilities exhibit underemployment. Second, greater dispersion improves aggregate productivity in countries that experience underemployment, but worsens productivity where there is assortative assignment. Furthermore, the shape and size of factor endowments are shown to jointly determine a global pattern of comparative advantage. Countries are more likely to export their abundant factors when labor markets organize heterogenous workers effectively. These predictions receive empirical support from Organization for Economic Co-operation and Development (OECD) countries using measures of diversity constructed from educational attainment.