You need to sign in to do that
Don't have an account?
how to display list of values in Descending order
Hi, how to display list of values in Descending order .
apex Class :
============
public class SetPrimitiveDatatype
{
public set<String> fstName{get;set;}
public SetPrimitiveDatatype()
{
fstName=New set<String>();
fstName.add('Rama');
fstName.add('Anil');
fstName.add('Srinu');
fstName.add('Kumar');
fstName.add('Prasad');
fstName.add('Devaraju');
fstName.add('Murali');
fstName.add('Balu');
fstName.add('Chaitu');
fstName.add('Tanuja');
}
}
page
============
<apex:page controller="SetPrimitiveDatatype">
<apex:form >
<apex:pageBlock title="Display The Set of values">
<apex:pageBlockSection title="FirstName">
<apex:pageblockTable value="{!fstName}" var="fn">
<apex:column value="{!fn}"/>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Please help me friends.............
All Answers
Hi!
Instead of using set use list. Once you have added the entries into the list call any std sort method. This would solve that.
Regards,
Manjunath
Not pretty sure whether you can do it like that. You might need to implement Comparable interface for this purpose.Please find the Link .http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_lists.htm#list_sobject_sorting
May be if it is a mandatory requirement then make use of Custom Setting and then Query Custom Setting objects with order By Column Name desc.
This should definetely Work.
i am a bigineer , i am solving sort , but i want to descending order list of values ........
in my code where i am modifing and adding the code methods...
please help me ..........
thanks
Hi !!!
You can create your own sort method. Once you have filled the data into list, call this function. Use your normal bubble sort.
Regards
Manjunath
Hi,
i dnt know how to create own sort method.
plz u create sort method and send me the code ...........
please help me.....
Hi,
i am here stuck ...........
plz help me.......
May be if it is a mandatory requirement then make use of Custom Setting and then Query Custom Setting objects with order By Column Name desc.
This should definetely Work.
Hi Palli,
try this link
http://success.salesforce.com/ideaView?id=087300000007bp4
hi,
please help me ,
for loop concept using descending order.................
Hi Sammy ,
Thank u very much ...................
can u please tell me that how to add list record...??
public class SortingClass
{
public List<Employee__c> sortEmp{get;set;}
public List<Employee__c> sortEmpDESC{get;set;}
public string sortExp = 'ASC';
Integer totalSize = 0;
public SortingClass()
{
sortEmp = new List<Employee__c>();
sortEmp = [select First_Name__c,Last_Name__c,Email__c,Phone_No__c,Designation__c,Salary__c
from Employee__c order by First_Name__c ASC];
// sortExp = 'ASC';
totalSize = sortEmp.size();
system.debug('-----totalSize-----'+totalSize);
}
public void sortByName()
{
sortEmp.clear();
sortEmpDESC = new List<Employee__c>();
if(sortExp == 'ASC')
{
for(Integer i=totalSize-1; i>=0; i--)
{
system.debug('-----Index-----'+i);
sortEmpDESC.add(sortEmp.get(i)); //My code is getting error in this line
system.debug('----sortEmpDESC----'+sortEmpDESC);
}
sortExp = 'DESC';
}
}
}