A Minecraft inventory sorting mod for Forge that works with vanilla clients.
Shift-right-click on an inventory slot to sort that inventory. With a Forge client (even without the mod installed!), middle-clicking in survival mode also works.
When sorting the player inventory, the hotbar is not reorganized, but existing stacks are refilled. This is done in the order: selected hotbar slot, offhand, rest of hotbar left-to-right.