Do a single topological sort considering all dependencies.
This doesn't guarantee items in the same group stay together. Items from different groups might interleave.
You need to sort both items within groups AND groups relative to each other.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
Do a single topological sort considering all dependencies.
This doesn't guarantee items in the same group stay together. Items from different groups might interleave.
You need to sort both items within groups AND groups relative to each other.