serializeXML: Refactor the attribute ordering code
serializeXML: Refactor the attribute ordering code

Rewrite the code for ordering attributes in the output and extract it
into a function.  As a side-effect, we ensure we only use the
`.item(index)` method once per attribute because it is inefficient
(see https://bugs.python.org/issue40689).

Signed-off-by: Niels Thykier <a802a5730c0da02a06106670cc12c7838c6e90dc@thykier.net>

oberstet/scour,codedread/scour,scour-project/scour,Ede123/scour