[英]Sort an ArrayList of HashMaps in Velocity
In a Velocity template, I have an arraylist of hashmaps. 在Velocity模板中,我有一个hashmap的数组列表。
Code sample: 代码示例:
#set($users = $userTool.getUsers())
##$users is an arraylist (java.util.ArrayList), each item a Hashmap (java.util.HashMap)
I'm struggling to do some sort in this array based on the value of a certain key from each Hash. 我正在努力根据每个哈希中某个键的值在此数组中进行某种排序。
I could achieve this using the SortTool from VelocityTools 我可以使用VelocityTools的SortTool实现此目的
https://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/SortTool.html https://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/SortTool.html
Will keep the question & answer to help others. 将保留问题和答案以帮助他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.