Theory is, write some php which will generate a javascript file containing the structure information in an array, then use some other javascript to do the sorting and rendering client-side.
For: removes the server side processing and does not require all pages to be parsed as php
Against: need to remember to run the php to update the structure file after each navigation change.
I can develop it in this page.
First: PHP code to render some basic javascript hello world: