How do I create a sorted map or tree map in velocity templates using liferay?
I am creating a velocity template in liferay portal. I use a HashMap
to store some key/value pairs.
I am creating a HashMap
like this
#set ($myHashMap = {
'key1': 'value1;',
'key2': 'value2;',
'key3': 'value3;',
})
and I access the hashmap using
$myHashMap.get('key1')
I want to iterate over my hashmap and print all the key/value pairs.
But since the ordering is not maintained in HashMap
, I want to use a TreeMap/SortedMap. I am new to velocity templates. Also, I know how to do it in java, but unfortunately the glitch is I have to find a work around in velocity templates.