I have 4 HTML divs (with nested divs) and sort numbers for each of the divs that can be returned from a function. I'd like to sort the divs based on the sort numbers returned from the function.
What's the best way to do this? I am thinking of arranging the divs in an array like this:
$array[$sort_order] = $div;
which will translate to
$array[1] = "<div class='container'><div class='caption'>One</div><div class='text'>....</div></div>";
$array[2] = "<div class='container'><div class='caption'>Two</div><div class='text'>....</div></div>";
$array[3] = "<div class='container'><div class='caption'>Three</div><div class='text'>....</div></div>";
$array[4] = "<div class='container'><div class='caption'>Four</div><div class='text'>....</div></div>";
and then use ksort() to sort them before displaying.
I was wondering if there is a better way to do this?