Lately I started running Interwiki.py on Commons, after getting frequently annoyed that existing interwikis are frequently incomplete, incorrect or missing. Commons has some unique peculiarities related to interwikis, since most links point from Commons categories to Wikipedia articles while Wikipedia articles do not have interwiki links to Commons (only links though [[template:Commons category]]).
I could not get existing code to work, but with small tweeks to interwiki.py and commons_family.py I got it working. Everything was going smoothly for few 10k pages, until my bot (user:JarektBot) was blocked because it "Reorganises cat layout in a standard for which there is no consensus". Apparently on Commons there is no standard if categories go before interwikis or interwikis before categories, and according to blocking admin, bots are expected to leave the page in the order in which they found it.
I studied the interwiki.py, commons_family.py and wikipedia.replaceLanguageLinks function, but as far as I can tell there is no parameter or an easy tweek which would allow me to preserve interwikis/categories order. Am I correct?
Is there any easy solution to this problem?
Jarek T.
(User:Jarekt on Commons)