Hello Jarek,

On 28 November 2011 06:14, Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI@saic.com> wrote:
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.

Is there any easy solution to this problem?

No, not really. At the moment, what happens is this: first, all interwiki links are removed from the page. Then, they are added to the bottom of the page.

This is - in general - a hard problem to work with. For instance, how should a page like

"blah text [[en:interwiki]] blah blah



be adapted? And how should a page like

"blah text




be adapted?

Changing the output to a different, but well-defined order is not that hard. Determining the correct order is. 

In this case, there are two options: thinking up some heuristic and implementing it, or doing some politics ('hey, if you don't *want* interwikis....'). 

If you want to work on the heuristic, the replaceLanguageLinks function in pywikibot/textlib.py is where you'd want to start.

Good luck (with either method ;-))!