Coincidentally, it kind of simplifies the sorting problem too. Just do like Amazon and don't sort!
Instead, use the machine to figure out exactly what was in that bin you just bought. Give the bin an ID, and store it as is. Then, when putting together a set, have your software find the minimum number of bins you need to pull from to assemble the set. Run them through, and have the machine pull the parts.