In my pursuit using JavaScript, I am striving to fit a group of objects of set sizes into a container with a specified horizontal width, all while preserving their approximate initial order. While whitespace is not a major concern, the goal is to keep it to a minimum.
For a small number of objects, I can manually achieve this in a tetris-style layout.
| +---+ +-----+ |
| | 1 | | 3 | |
| +---+ +-----+ |
| +------+ |
| | 2 | |
| +------+ |
| +--+ +----+ |
| |4 | | 5 | |
| +--+ +----+ |
Although my JavaScript skills are decent, I am eager to find some sample code or algorithms that can serve as the foundation for my implementation. I am aware that this information likely exists somewhere, I'm just uncertain about what exactly to search for.
— Harold