Leaving the Nest
Mathematica, 56 54 52 bytes
-2 bytes due to Alephalpha.
-2 bytes due to CatsAreFluffy.
Cases[#,_?AtomQ,{i}]~Table~{i,Depth@#}/.{}->Nothing&
Actually deletes empty levels.
Pyth, 17
us-GeaYsI#GQ)S#Y
The leading space is important. This filters the list on whether the values are invariant on the s
function, then removes these values from the list and flatten it one level. The values are also stored in Y
and when we print we remove the empty values by filtering if the sorted value of the list is truthy.
Test Suite
Alternatively, a 15 byte answer with a dubious output format:
us-GpWJsI#GJQ)
Test Suite
Expansion:
us-GeaYsI#GQ)S#Y ## Q = eval(input)
u Q) ## reduce to fixed point, starting with G = Q
sI#G ## get the values that are not lists from G
## this works because s<int> = <int> but s<list> = flatter list
aY ## append the list of these values to Y
e ## flatten the list
-G ## remove the values in the list from G
S#Y ## remove empty lists from Y
Python 2, 78 bytes
f=lambda l:l and zip(*[[x]for x in l if[]>x])+f(sum([x for x in l if[]<x],[]))