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.
And we didn't have an idea of the complete contents in our heads ahead of time either; we just had to deal with whatever came down the chute one piece at a time. (Though you might be able to store 5-6 pieces off to the side, but that gets clumsy fast.)
One strategy to try to accommodate that randomness would be to have a lower row for one size-range, progressing horizontally, then another row on top of that in the same tier, for some other size-range. Going even further you could even start a second tier in front of that, with two more sizes. But that also could screw you if the one in front (or on top) starts to get too far ahead of the one behind (or on the bottom). Then you're back to setting packages aside and tripping on shit...