0

I have a list that I created with a Wrapper Class and a Comparable/compareTo method. So it is sorted the way I would like it. From this list I created a Map with the key being the list's Created Date. I did this because I needed a table with a list of items under each Created Date. I formatted the date into a string. I now need to sort the Key in DESC order so the most recent date is on top.

To sort the keySet, once I create the the List of keySet, how do I pull the value from the map and match it to the List?

        keys = new List<String>(dateHeader.keySet());
        keys.sort(); 
        for(String st : keys){
           //now what? 
           //something along the lines of: 
           //resortedMap.put(st, st.???);
        }

my map is: Map<String, CaseInfo[]> dateHeader

1 Answer 1

3

Sets are never sorted. Instead, expose the list directly to Visualforce, and then iterate over each key value.

<apex:repeat value="{!sortedKeys}" var="key">
    <apex:repeat value="{!caseMap[key]}" var="caseInfo">
        ...
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .