Optimality in Self-Organized Molecular Sorting