Hello,
Coud be don like bellow but sorttool offers more features
1. Create an object encapsulating sorting logic
(with your objects implementing Comparable or you can add a Comparator) :
public class Sorter {
public Sorter() {
}
public void sort(List list) {
Collections.sort(list);
}
}
2. pass it to the Velocity context
context = new VelocityContext();
context.put("sorter", new Sorter());
3. use it on lists in your template
$sorter.sort($books)
Philippe
Florin Vancea wrote:
cha wrote:
Hi All,
Am trying to sort the list of First Alphabets of merchants but cant able to
do that. It seems that Collections.sort($List)) is not working.
Below is my sample code:
#foreach ($merchant in $merchants)
#if (!$List.contains($merchant.getName().substring(0,1).toUpperCase()))
#set ($boolean =
$List.add($merchant.getName().substring(0,1).toUpperCase()))
#end
#end
Collections.sort($List))
Please do let me know, how to accomplish sorting in Velocity.
Cheers,
Cha
--
Philippe Collignon
IT Consultant
Starobject S.A.
Rue Principale, 56
L-5367 Schuttrange
Luxembourg
+352621312040
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]