sort tool by name?

lauren.fraser's Avatar

lauren.fraser

14 Jun, 2014 10:57 AM

I'm trying to sort by name and I'm not getting the results I intended. Here is my script:

#set ($folderPages = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-page[name != 'index']"))
#set ($folderName = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure/folder-name"))
$_SortTool.addSortCriterion("name", "", "text", "ascending", "") 
$_SortTool.sort($pageName)
#foreach ($folderPage in $folderPages)
    #set ($folderTitle = $folderPage.getChild("title"))
    #set ($folderPath = $folderPage.getChild("link").value)
    #set ($pageName = $folderPage.getChild("name"))
    <p><a href="${folderPath}">$_SerializerTool.serialize($folderTitle, true)</a></p>
    #end

And a sample of the xml from the index block:

<system-page id="5012122bac1009d0012b97c0bd8cd7f9">
<name>bravata-kurt</name>
<is-published>true</is-published>
<last-published-on>1397571471628</last-published-on>
<last-published-by>lfraser</last-published-by>
<title>Kurt Bravata, MD</title>
<start-date>1375280220000</start-date>
<display-name>Kurt Bravata, MD</display-name>
<path>/physicians/bravata-kurt</path>
<site>citizensmemorial.com</site>
<link>site://citizensmemorial.com/physicians/bravata-kurt</link>
<created-by>lfraser</created-by>
<created-on>1392912765389</created-on>
<last-modified-by>lfraser</last-modified-by>
<last-modified>1392912818060</last-modified>
</system-page>

This is basically a provider listing, the Display Name and title show the full name, and we want an alpha sort by last name. Since the page names are in the format lastname-firstname, I thought it would be the easiest way to sort.

Thanks in advance,
Lauren

  1. 1 Posted by Ryan Griffith on 16 Jun, 2014 01:36 PM

    Ryan Griffith's Avatar

    Hi Lauren,

    My apologies for the incomplete response, I accidentally hit submit. Didn't have my morning coffee yes :)

    As I was saying, it looks like you are close, but may not be sorting the correct variable. When you have a moment, try the following:

    #set ($folderPages = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-page[name != 'index']"))
    $_SortTool.addSortCriterion("name", "", "text", "ascending", "") 
    $_SortTool.sort($folderPages)
    

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by lauren.fraser on 16 Jun, 2014 02:22 PM

    lauren.fraser's Avatar

    Ryan,

    That did the trick. Thanks!

    Lauren

  3. 3 Posted by Ryan Griffith on 16 Jun, 2014 02:23 PM

    Ryan Griffith's Avatar

    Thank you for following up, Lauren. I am glad to hear that did the trick.

    Have a great day!

  4. Ryan Griffith closed this discussion on 16 Jun, 2014 02:23 PM.

Comments are currently closed for this discussion. You can start a new one.

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