Tools | Options | Advanced | Config editor

user.js:

user_pref("mail.check_all_imap_folders_for_new", true);
user_pref("mail.server.default.check_all_folders_for_new", true);
user_pref("mail.imap.expunge_after_delete", true);
user_pref("mail.password_protect_local_cache", true);
user_pref("alerts.totalOpenTime", 4000);
user_pref("extensions.enigmail.addHeaders” , false);
user_pref("general.useragent.override", "");

user_pref("layout.word_select.eat_space_to_next_word", false);
user_pref("layout.word_select.stop_at_punctuation", false);
user_pref("browser.urlbar.clickSelectsAll", false);
#user_pref("browser.cache.disk.parent_directory", "/mnt/ramdisk");
user_pref("browser.cache.memory.capacity", 65535);
user_pref("browser.cache.offline.enable", false);
user_pref("browser.cache.disk.capacity", 65535);
user_pref("browser.cache.disk.enable", true);
user_pref("browser.cache.memory.enable", true);
user_pref("browser.cache.disk_cache_ssl", false);

user_pref("mailnews.reply_header_authorwrote", "%s ");
user_pref("mailnews.reply_header_locale", "sl_SI");
user_pref("mailnews.reply_header_ondate", "@ %s");
user_pref("mailnews.reply_header_separator", "");
user_pref("mailnews.reply_header_type", 3);

user_pref("network.http.sendRefererHeader", 1);
user_pref("privacy.donottrackheader.enabled", true);
user_pref("general.useragent.override", "");

user_pref("mailnews.default_sort_order", 1);
user_pref("mailnews.default_sort_type", 18);
user_pref("mailnews.default_view_flags", 1);

To apply sorting order to all folders you must delete index files in Thunderbird profile folder:

find . -iname *.msf -exec rm -v '{}' \;

Usefull plugins:

*Remove duplicate messages