function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Sorting in a data table



I am trying to build the same sorting functionality we have in the Enhanced list view in a data table in my visualforce page. 


When the user clicks on the column the data is sorted wrt that column. My trouble is this data is coming from a webservice and is stored in form of arrays of a custom class instead of some object in salesforce. How do i perform the sort. 


Does visualforce or apex have any standard function or class to sort data. Or will i have to implement some sorting algorithm to do this.







Did you by any chance got to the solution . Please share asap as I am stuck at a point where i recieve documents from Website on VF Page and i want to sort that descending. 



Aamir khan 19Aamir khan 19
Hi Adil,
Below is the code to sort the data in table.
If you click on particular column it will sort the data.

<apex:page standardController="Account" >

<apex:includeScript value="//" />
<apex:includeScript value="//"/>
<apex:stylesheet value="//"/>

    $("[id$='accsTable']").tablesorter({theme: 'green'});

<apex:datatable value="{!account}" var="acc" id="accsTable" >
  <apex:column headerValue="Created">
    <apex:outputText value="{0, date, dd/MM/yyyy}">
      <apex:param value="{!acc.CreatedDate}" />
  <apex:column headerValue="Name">
    <apex:outputField value="{!acc.Name}" />
  <apex:column headerValue="Street">
    <apex:outputField value="{!acc.BillingStreet}" />
  <apex:column headerValue="City">
    <apex:outputField value="{!acc.BillingCity}" />
  <apex:column headerValue="State">
    <apex:outputField value="{!acc.BillingState}" />
  <apex:column headerValue="Postcode">
    <apex:outputField value="{!acc.BillingPostalCode}" />

Hope this will resolve your Que. :-)