You'd have to get full dimensional info about each package... probably not that hard. But to change the order, you've now got a storage problem. Where previously your analysis was confined to just one package, now you're dealing with groups of N packages, and depending how far you want to take the optimization, N could be as big as "all packages destined for that truck." So maybe you have some kind of sort area between the inbound & outbound areas. Or maybe you use the conveyor itself as the storage - i.e. if something is out of order, it just makes a circuit around the building until its turn comes. That would probably require a bigger/longer conveyor, and to compensate for lower "density" of chute-appropriate packages, it would have to move faster.
Suddenly this seems akin to the problem of optimizing spinning disc drives, starting from slow ones in the old days and moving forward. What you're essentially calling for is something akin to random access, but instead of bytes we're accessing packages!
Edit: Or the hybrid version: you create multiple, smaller sorting areas somehow, one for each bay, located near the bay.