I have this kind of adjacency list:
I need to sort it to this: 2, 7, 9, 10, 8, 16, 17, 11
Basiccaly I have table where I have stored posts with parent ids. I can have unlimited number of levels.
I need just algorithm or full code in PHP.
I tried to use variations of row/column prefixes and some recurrent functions.