Where the data is coming from?

the data is coming as a list of records of custom type from a webservice and it is happening realtime.

Component used to display the data in VF page:

i am using pageblocktable to display the data in a tabular format in my vf page. Now the issue is to make the table sortable based on some columns like "Amount", "Payer Name", etc. So, when an user clicks on a a particular column for ex., say Payer it should sort the entire table either ascending or descending if it is a numeric column or in alphabetical order.


The issue is there is no SOQL query used to issue a "order by" clause but a List of custom type.


How could i achieve the sorting of pageblocktable when there is no SOQL query or concrete SObject is not there? Expert advise is very much helpful here...

  • Do you have the data in your controller or just on your page?
    – greenstork
    Commented Apr 1, 2014 at 14:45
  • 3
    Personally I favour doing that sort of work at the client-side in JavaScript using one of the jQuery table plugins. My favourite at the moment is this one force201.wordpress.com/?s=datatables&submit=Search. I'll be interested to see what detailed answers you get though.
    – Keith C
    Commented Apr 1, 2014 at 14:45
  • Thanks @KeithC, the article is good and gives me lot of idea to start. But the issue is the custom list that is what the road block here. Okay, let me look for any other options somewhere or any alternate ideas that would be coming here...
    – Bforce
    Commented Apr 1, 2014 at 14:56
  • @baskaran Don't quite follow you... You can sort client-side or server-side and because SOQL isn't available you are going to have to do some work either way. Client-side gives instant response whereas server-side is always sluggish. But there are many factors to consider.
    – Keith C
    Commented Apr 1, 2014 at 15:01
  • You can use Keith C's suggestion even with a custom list. Basically, you can download the full list of data (as JSON for example) and use a client side solution to sort it, tablesorter is one but there are many other libraries.
    – PepeFloyd
    Commented Apr 1, 2014 at 15:01

2 Answers 2


If you want to sort in Apex, you can use the Comparable interface. Create a wrapper class that implements Comparable, and then modify the compareTo method to look at a "sortBy" field for determining whether to sort by amount or player name.

See the following SSE question for more information: How to sort Wrapper list?


have a look at this. Also, since your data is coming from external source, u could create a wrapper class for the incoming data. http://blogforce9.blogspot.in/2012/08/sort-able-pageblock-table-component-for_23.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .