I have a visualforce page where I am displaying dynamic picklist
Visualforce code:
<apex:selectList value="{!SelectedNomination}" size="1" id="a">
<apex:selectOptions value="{!contactlist}"></apex:selectOptions>
</apex:selectList>
Apex Code:
public List<Nominator__c> Nominators = new List<Nominator__c>();
public List<SelectOption> contactlist
{
get
{
String state =
application.Congressional_State_Territory__c.substring(0,2);
Nominators = [Select Id, Name, Class_Year__c, Contact_Name__c,
Nominator_Code__c, Nominator_Type__c from Nominator__c WHERE
FirstTwoLetters__c =: state and Nominator_Type__c=
'Congressional - House' and Class_Year__c =:
application.Class_Year__c and Status__c =:'Active' ];
contactlist = new List<SelectOption>();
for(Nominator__c nom : Nominators)
{
contactlist.add(new SelectOption(nom.Id, nom.Name + ' ' +
nom.Contact_Name__c));
}
**contactlist.sort();**
return contactlist;
}
set {}
}
The data in my picklists are as "Florida District 01 Peter Scott" , "Florida District 02 Bob Stu", District 03 Matt Cauller", ..... goes onto Distrcit 14.
I have used the sort function above before displaying the picklist. It displays all other values in correct order except District 01 and 14. Their position is reversed.How do I make them display in their correct position. This is how it displays
Florida District 14 .........."
Florida District 02 .........."
................03...........
................04..........
...............05........
...............06.......
...............07......
.........................
.........................
Florida District 01 .........."