I made a demo a while back with three ways to build a search interface with sortable columns. It might be of interest to you..
If the view has a lot of data (more than a thousand entries), you're probably better of setting the columns sortable in the notes view/using a view panel. The reason is that the methods used in blogpost are quite resource hungry (CPU/memory).