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

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">
        ...
  • ah yes. Thank you that was silly of me! – Olivia Jul 26 '17 at 23:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.