How can I loop through a Map or List in reverse order in VF?
or
Can I reverse the order of a map in Apex?
Here is my code:
String nsp = PackageUtils.namespacePrefix;
Map<String, String> fieldset = new Map<String, String>();
List<Schema.FieldSetMember> fieldSetMemberList = getFieldSet(nsp + 'Search_Table', nsp + objectName);
for(Schema.FieldSetMember fieldSetMemberObj : fieldSetMemberList) {
fieldset.put(fieldSetMemberObj.getFieldPath(), fieldSetMemberObj.getLabel());
}
Here is the VF:
<apex:repeat value="{!fieldset}" var="field">
<th>{!fieldset[field]}</th>
</apex:repeat>
This shows Description, Id, Name
in VF, but I want to show Name, Id, Description
.
Set<Object>
, and similarly unordered), or over the map's values. What is the type of your map? Is it something likeMap<Id, List<sObject>>
?Map<String, String>
and yeah, I guess I"m looping the keyset.