Tidy Wand
Sort your inventory and chests with one wand.
Craft it with a chest, a stick, and a paper. Hold it and press use. If you're looking at a chest, barrel, or shulker box, it gets sorted without opening. If you're not looking at anything, your inventory gets sorted instead.
Partial stacks are merged, and your items keep their names, enchantments, and durability. Your hotbar stays protected.
There are three sort modes: category, name, or amount. Sneak and use the wand to switch between them. If you don't like the result, type /tidywand:undo to put everything back.