fix invalidations from loading Static.jl (#46761)
* improve type stability of `sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, o::Ordering)`
* improve type stability of `fmt(buf, pos, arg, spec::Spec{T}) where {T <: Strings}`
This fixes some invalidations when loading Static.jl.