How to add add sorting to html table fields

Hi Please help to find how to add sorting to all fields in html table ,
backend is mongoid and also iam using kaminari gem for pagination.

Just sort the data before you pass it to the view for inclusion in the table.

Colin