Intense (for me) sorting algorithm
I'm writing a label printing application for work.
Basically it needs to sort item quantities into containers. Currently I'm sorting into boxes full of one item, and leaving a sorted list of items that are left over (those that don't fit into containers fully).
My question is, what's the best approach for developing an algorithm that can sort them into boxes, trying to fill as many boxes as possible, while keeping the remaining items together. For example:
Containers can hold 4.
"Type 1", 2.
"Type 2", 3.
"Type 3", 1.
"Type 4", 2.
"Type 5", 3.
In this instance, "Type 2" and "Type 3" would go in a box, "Type 1" and "Type 4" would go in a box, and "Type 5" would remain by themselves. Items need to stay together (no splitting into separate boxes). Also, the amount that a container can hold should be variable.
Any help or insight would be appreciated.