Sorting a list based on base property
I'm having trouble sorting a list of numbers in descending order
I have a list:
$list = [1434816000000, 1427385600000, 1427126400000, 1428336000000, 1429545600000, 1430755200000, 1431964800000]
And I want to sort it so I used:
#set ( $sortedChildren = $_SortTool.sort($list) )
But I can't figure out how to set it in descending order. I tried the following and it didn't work.
#set ( $sortedChildren = $_SortTool.sort($list, ":desc") )
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 18 Jun, 2015 08:04 PM
Hi,
The Sort Tool will only accept multiple arguments if you are attempting to sort a map, but not an array.
One issue you will run into is that Velocity will generate an ArrayList when using the
[1,2,3]
notation, so you need to convert it to a native Array before passing it into the Sort Tool. This still won't allow you to specify the direction; however, so you basically need to sort and then reverse the array using a loop. Consider the following:Please let me know if you have any questions.
Thanks!
Tim closed this discussion on 30 Jun, 2015 06:45 PM.