provider resolver perf improvement

move the sorting of the providers to after we make the first cut, still
keeps deterministic ordering, but avoids sorting providers we are just
going to throw away.