Sorting Modules

Hello,
second try with this post,
I would like to create 4 types of groups:

  1. 6 modules 2. 7 modules 3. 8 modules 4. 9 modules
    and i would like to apply these groups on these cubes:

    and to find a way to control the way the groups are applied on the cubes.
    for example a maximum of the 6 modules groups, or a minimum of the 8 modules groups.

but i am so light in grasshopper that i don’t even have a direction, or a starting point
so any help will be much appreciated.
module sorting.gh (131.1 KB)

duplicate thread, please don’t do that