This uses f-strings for string interpolation, which means this only
works for Python 3.6+, but is more readable.
It also moves the requirement sorting logic into the metadata output
function. Since the sorting logic exists mainly for the purposes of
reproducible builds, it is better to abandon the idea of a
case-insensitive comparison, and to sort as late in the process as
possible (so that anything before the sort can remain agnostic to the
order).