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
Praful_GuptaPraful_Gupta 

sorting of custom text field for visual force

I have a question related to sorting of custom text field for visual force

Scenario, there is custom field with label account number as text field but it has data as numbers and I want to display it in visualforce,
example: this text field (Account_Number__c) has numeric values like 1, 19, 35 etc. Visualforce page displays these values as 1, 35 ,19
how can I sort them as 1,19,35 ?

My query look like :
[select id, Name, high_months__c, low_months__c, Account_Number__c from Company_Account__c where Account__c = :accId Order By Account_Number__c DESC];
Above, I want to sort by Account_Number__c which is text field with data as numbers but in visualforce I am not getting sorted data, please help?
logontokartiklogontokartik
Hi Praful,

Whatever you are doing seems to be right. I am not sure why you are not getting the ordered accts in page, you query seems to be right, can you post you complete code and page ?

Are you using list to display on the page?
 
Dushyant SonwarDushyant Sonwar
Hi Praful,
Your Data has been Sorted according to String literals. You Have to use a Wrapper to Achieve your Sorting .
See This...
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_list_sorting_sobject.htm
Dushyant SonwarDushyant Sonwar
this will also help you..
See this..
http://sforcecodes.blogspot.in/2011/10/apex-sorting-of-list-collection-in.html