The following is my DB data, how can I sorting it by sid and prev\_sid with php/mysql!?

```
sid prev_sid    type
000 197         app_home    
197 198         page_teach  
198 218         page_teach  
199 211         page_step   
211 207         link        
218 559         page_step   
559 199         page_step

```

Result:

```
sid prev_sid    type
000 197         app_home
197 198         page_teach
198 218         page_teach
218 559         page_step
559 199         page_step
199 211         page_step
211 207         link

```

000 --> 197 --> 198 --> 218 --> 559 --> 199 --> 199 --> 211 --> 207