Multiple attributes sorting of array - preferably not "table"

Hello,

is there any pattern how I can sort array of objects based on primary and secondary sort attribute ?
That array is sub-document in minimongo. (so no aggregation)

I would really prefer UL LI over table.
So prepared package, or data crunching algorithm.
Or link to some best practice algorithm in lets say JS/PHP/C++/Delphi, Pascal or maybe some other I can read

Ok, I pick “thenBy” from http://microjs.com/#sort

Love that site.

Time to wrap mini-library to meteor package.

And as I am lazy, I found already something like that in npm and even smaller footprint on github, but the minified file is smaller for thenBy
https://www.npmjs.com/package/sort-by