You need to sign in to do that
Don't have an account?
John Neff
How do I set items in an array to appear in alphabetical order?
Hello,
Using this article (http://blog.jeffdouglas.com/2011/03/02/dynamically-group-display-query-results/) I have created a VF page and controller that dynamically groups custom object records by their associated campaign.
It works great, except the campaigns in the array seem to display in random order on the VF page - and my users don't like that!
Is there a way that I can tweak my controller (shown below) to make the array of campaigns appear in alphabetical order?
Here is my controller:
Thanks in advance!
John
Using this article (http://blog.jeffdouglas.com/2011/03/02/dynamically-group-display-query-results/) I have created a VF page and controller that dynamically groups custom object records by their associated campaign.
It works great, except the campaigns in the array seem to display in random order on the VF page - and my users don't like that!
Is there a way that I can tweak my controller (shown below) to make the array of campaigns appear in alphabetical order?
Here is my controller:
public with sharing class AllSpotController{ public List <Job_Number__c> SPOT {get;set;} public String[] campaigns {get;set;} public void load() { SPOT = [Select id, name, Thumbnail_URL__c, ISCI__c, Title__c, Project__c, Campaign__r.Name, Nets_Running__c, View_Link__c, Internal_Title__c, Legal__c from Job_Number__c where ISCI__c <> null]; Set<String> campaignSet = new Set<String>(); for (Job_Number__c j : SPOT) campaignSet.add(j.Campaign__r.Name); campaigns = new String[campaignSet.size()]; Integer i = 0; for (String campaign : campaignSet) { campaigns[i] = campaign; i++; } } }
Thanks in advance!
John
i forgot to initialize the list ! :)
All Answers
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm#apex_System_List_sort
-Praveen K Hari
Is there any chance that you could help me diagnose?
Thanks,
John
i forgot to initialize the list ! :)
If you could indulge me one more time? Want is the differnce between the two? I'd love to understand how this thing actually works!
John
Thank you!!!
A "array notation" of a list using [] can only be one dimensional
Please refer below link:
http://salesforce.stackexchange.com/questions/5447/is-there-a-difference-between-an-array-and-a-list-in-apex/5450