You need to sign in to do that
Don't have an account?
Madhura B
String to Integer in SOQL
Hi,
I have a text field which holds numeric values like 1, 2, 3, 12,13 etc. Visualforce page displays these values as
1
12
13
2
3
how can I sort them as 1,2,3,12, 13.... Guess I can't use lpad in soql.
Try using list's sort method
Take one list for that oupt values
List<Integer> varlist=New List<Integer>();
use for loop
then convert one by one into Integer
x=Integer.valueof(-------);
varlist.add(x);
sort the list like
varlist.sort();
Prem
I don't think I can do that.
The code is as follows
Format list is then displayed on VF.
Which field values you want to sort??
Master_Column__c which is a text field holding numbers
Hi follow this code
List<String> formatList=new List<String>();
List<Integer> realform=new List<Integer>();
for(Format_Conversion_Table__c f:[Select Sublevels__c,Master_Column__c, KS5_Points__c, KS5_Grades__c, KS4_Points__c, KS4_Grades__c,KS3_Points__c, Id, BTECLevel3__c, BTECLevel2__c, BTECLevel1__c From Format_Conversion_Table__c Order By Master_Column__c ASC ])
{
formatList.add(f.Master_Column__c);
}
for(String s:formatList){
realform.add(Integer.valueOf(s));
}
realform.sort();
System.Debug(realform);
Using two for loops is not even required over here. In first loop itself you could collect the type-casted list of Integers and sort them.