Improve performance of sort_folder_list() method.

Now sorting 25k folders takes around 3 seconds.