Sort stacks/flashcards by name and various optimizations