Sorting list by 3 varying variables

This is doing my head in. I have 3 lists that will all vary. The levels, plan and parts.

In the example at the bottom I want to end up with

Level 0 Floor part A
Level 0 Floor part B
Level 0 Floor part C
Level 0 Floor Part D
Level 1 Floor part A
Level 1 Floor part B
Level 1 Floor part C
Level 1 Floor Part D
Level 0 Structure part A
Level 0 Structure part B
Level 0 Structure part C
Level 0 Structure Part D
Level 1 Structure part A
Level 1 Structure part B
Level 1 Structure part C
Level 1 Structure Part D

then lastly will be the ceiling part in the same list format. Is there a way to cycle and transpose these lists so I can order them to put them together like that with varying inputs for level plan and part? Thanks for any help

well looks like typing it out in cyber space to organize my brain seems to have solved it but im skeptical

heres 4 Levels 2 plans 5 parts

so if I’m correct:

  1. you get the levels
  2. you get the plans of those levels
  3. you create a number of “parts”
list_plans = ["floorplan", "structure", "ceiling"]
list_levels = ["level 1", "level 2", "level 3", "level 4"]
parts = ["A", "B", "C", "D"]
prefix = "PART "

for level in list_levels:
    for plan in list_plans:
        for part in parts:
            print (level, plan, prefix, part, sep=" ")

level 1 floorplan PART A
level 1 floorplan PART B
level 1 floorplan PART C
level 1 floorplan PART D
level 1 structure PART A
level 1 structure PART B
level 1 structure PART C
level 1 structure PART D
level 1 ceiling PART A
level 1 ceiling PART B
level 1 ceiling PART C
level 1 ceiling PART D
level 2 floorplan PART A
level 2 floorplan PART B
level 2 floorplan PART C
level 2 floorplan PART D
level 2 structure PART A
level 2 structure PART B
level 2 structure PART C
level 2 structure PART D
level 2 ceiling PART A
level 2 ceiling PART B
level 2 ceiling PART C
level 2 ceiling PART D
level 3 floorplan PART A
level 3 floorplan PART B
level 3 floorplan PART C
level 3 floorplan PART D
level 3 structure PART A
level 3 structure PART B
level 3 structure PART C
level 3 structure PART D
level 3 ceiling PART A
level 3 ceiling PART B
level 3 ceiling PART C
level 3 ceiling PART D
level 4 floorplan PART A
level 4 floorplan PART B
level 4 floorplan PART C
level 4 floorplan PART D
level 4 structure PART A
level 4 structure PART B
level 4 structure PART C
level 4 structure PART D
level 4 ceiling PART A
level 4 ceiling PART B
level 4 ceiling PART C
level 4 ceiling PART D

1 Like

so good! thanks man

yw. hope this will help untangle your brainwaves :wink:

1 Like