Group by Key Issue

Hi All,

I’m trying to group by story a selection of floors (including foundations), but I can’t get what I want.

This is my script, but finally when I ask for it to show me only the 3 lower floor elements, it shows me the elements in the image below.

The python node just arrange me the data of the levels in the groups that I want:

lista = IN[0]
niveles = IN[1]
may_nivel = max(niveles)
resultado = []
excluidos = []

excluidos = []
for i in lista:
	if i > may_nivel:
		excluidos.append(i)
		

for i in niveles:
	aux = []
	for j in lista:
		if j == i:
			aux.append(j)
	resultado.append(aux)
	
resultado.append(excluidos)

OUT = resultado	

what am I missing here?

Thanks in advance!

Got it!.

Just in front of my eyes.