Replace x.sort_by!.select! with x.select!.sort_by!

The latter has the same speed as the former in the worst case
and faster in general, because it is always better to sort less items.

Unfortunately, `routes.select!{...}.sort_by!{...}` is not possible here
because `select!` returns `nil`, so select! and sort! must be done
in two steps.
Merge pull request #15836 from DNNX/router-swap-select-sort

Replace x.sort_by!.select! with x.select!.sort_by!