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
pallipalli 

How to display set of values in Ascending and Descending Order

Hi , how to display ascending order and descending order set of values in visualforce page......

apex class

===========

public class SetPrimitiveDatatype
{
public set<String> fstName{get;set;}
public set<String> lstName{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 .............

Gunners_23Gunners_23

Use "List" instead of "Set" and checkout the below link for sort function in list for sorting the values

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_list.htm

pallipalli

Hi , i dnt get in .........

 

please help me 

Laxman RaoLaxman Rao

You cannot sort the set because it a un-ordered collection.

So use list and use sort() method.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_list.htm

 

search for sort in this link

pallipalli

Hi Laxman ,

 

i am codeing beginner , how to use in class , 

 

so plz help me Laxman..............

Laxman RaoLaxman Rao

apex class

===========

public class SetPrimitiveDatatype
{
public list<String> fstName{get;set;}
public list<String> lstName{get;set;}

public SetPrimitiveDatatype()
{
fstName=New list<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');

fstName.sort();

}
}

pallipalli

Hi 

 

this the error message/..............

 

SetPrimitiveDatatype Compile Error: Method does not exist or incorrect signature: [SET<String>].sort() at line 20 column 9

Laxman RaoLaxman Rao

dude use list instead of set.

do not use set.

pallipalli

hi Laxman ,

 

i wnt ASC and  DESC order  of set of fstname values ............

 

 

pallipalli

Hi laxman ,

 

thanku very much ..........

 

now completed.................

 

now how to view list of values in Ascending order and descending order...........