Just incase you didn't spot it - I didn't for the longest time - there's three icons in the middle along the top bar of your backpack inventory when you're interacting with a storage unit.
The first - like an arrow alongside a list - will auto-sort your backpack ... and I'd never touch that. The middle one with the single arrow going into the box, double click it and it will put anything into the storage crate your are accessing that is already in the storage crate, creating new stacks as necessary. You can go from crate to crate and quickly dump the general stuff that is already in that box from your backpack, letting you simply sort the final dregs.
Just remember to take back anything you need - like shotgun shells, arrows or lockpicks, first aid bandages, food or drink... Wouldn't be the first or the last time I've left the base having dumped something vital.