I now have a bunch of email accounts each with their own IMAP folders. It has been terribly annoying that they always show up in the order in which the accounts were added and there is no way to sort them. I finally came across a Thunderbird plugin called ‘Folderpane Tools‘ which allows you to change the order of the accounts.
It still isn’t ideal. Any changes have to be done through the little plugins window and require Thunderbird to be restarted. Oh well, I guess its better than nothing.