I have a custom List button that links to a Visualforce page. I want the records selected in the Visualforce page to populate in a certain order. Any suggestions for accomplishing this? I've included my code below:

  <apex:includeScript value="{!$Resource.UtilJS}" />
      <apex:pageMessages />
        Note: All modifications made on the page will be lost if Return button
        is clicked without clicking the Save button first.
        <apex:commandButton value="Save" action="{!save}" />
        <apex:commandButton value="Cancel" action="{!cancel}" />
      <apex:pageBlockTable value="{!selected}" var="a" id="table">
        <apex:column headerValue="Name">
          <apex:outputField value="{!a.name}" />
        <apex:column headerValue="Order Start Date">
          <apex:inputField value="{!a.Order_Start_Date__c}" />
        <apex:column headerValue="Order End Date">
          <apex:inputField value="{!a.Order_End_Date__c}" />
        <apex:column headerValue="Term Length">
          <apex:inputField value="{!a.Term_Length__c}" />
        <apex:column headerValue="Allotment">
          <apex:inputField value="{!a.Allotment__c}" />
        <apex:column headerValue="Sales Price">
          <apex:inputField value="{!a.Sales_Price__c}" />

1 Answer 1


You can't do this without a controller or a JavaScript function. The native StandardSetController does not automatically sort the records in any documented manner, nor can you customize the ordering with just a simple tag or attribute.

  • i'm just learning how to do apex - can you point me in the right direction on any resources that will help me create a custom controller to accomplish this? Commented Jun 23, 2020 at 20:23

You must log in to answer this question.

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