I have a table for categories like this:
id parentid Title
1 0 Parent1
2 1 Child1
3 0 Parent2
4 3 Child2
5 1 anotherChild1
6 3 anotherChild2
How can I sort it in this order:
Parent1
child1
anotherchild1
Parent2
child2
anotherchild2
and save the order into another field called sorted index?
This should work for any level of hierarchy