How to sort array items in a user macro using velocity?

I want to displays members of a group, sortet by the displayName instead of the username.
Something like this:


#set($memberslist = $userAccessor.getMemberNamesAsList($group))

#set($myArrayList = [])
#foreach( $member in $memberslist )
  $myArrayList.add( {"fullname" : $action.getUserFullName($member) }) 

#foreach( $item in  $sortTool.sort($myArrayList, "fullname:asc") )
   <li> $item.toString()



This does not work for me. Can you help me?

2 answers

Have you looked at this one:

It helped me with my sorting issues :)


many thanks. Sorry, I didn't reply to your hint.

Unfortunately that solution didn't work for me. I got an exception error.

So that request is still open (for me). Any idea (someone else)?

I have now a new similar task: I get the descendants of a given page in a user macro. I want to sort that pages by the last-modify-date. Again: how can that be done?

My user macro so far:


## Macro title: Page descendants
## Macro has a body: N
## List all descendant pages below a give page 
## Developed by: Stefan Baader
## Date created: 13/10/2015
## Installed by: Stefan Baader

## @param Page:title=Page|type=confluence-content|required=true|desc=Select a page do use

#set( $pages = $pageManager.getPage($space.key, $paramPage).getDescendants() )

Descendants of page "${paramPage}"

<th style="white-space:nowrap;">Vers. Nr.</th>
<th style="white-space:nowrap;">Aktualisiert am</th>
#foreach( $page in $pages) 
<a href="$req.contextPath/pages/viewpage.action?pageId=$">$page.title</a> 
<td style="white-space:nowrap;">

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

1,474 views 114 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you