0 of 1 found this page helpful

List.Reverse

    Table of contents
    1. 1. Usage Restrictions
    2. 2. Parameters
    3. 3. Result
    4. 4. Samples
    list.Reverse(list : list) : list
    

    Reverse the entries in a list.

    Usage Restrictions

    1.9.1 or later

    Parameters

    Name Type Description
    list
    list The list value.

     

    Result

    a reverse ordered list of the original list.

    Samples


    Output

    to reverse a list:

    {{list.reverse([1,2,3]) }} 

     

    [ 3, 2, 1 ]
    Was this page helpful?
    Tag page
    Viewing 5 of 5 comments: view all
    This doesn't seem to work as expected. I tried
    var page = wiki.getpage( '/Committees_and_Task_Forces/Educational_Technology_Committee/Minutes' );
    if( #map.values( page.files ) == 0 )
    {
    web.html( "<p>No files are attached to page " .. page.name .. "</p>" );
    }
    else {
    foreach( var file in list.reverse(map.values( page.files ),'name'))
    {
    web.html(
    "<p>" ..
    "<a href='" .. file.uri .. "'>" .. file.name .. "</a><br />" ..
    "</p>"
    );
    }
    }

    and got very weird results, but not a reverse order list of the files attached to the page.
    Posted 05:49, 30 Jun 2011
    @greenbjb, I think you meant to use list.sort() instead. Also, you can avoid the use of web.html():

    var page = wiki.getpage( '/Committees_and_Task_Forces/Educational_Technology_Committee/Minutes' );
    if(!#page.files) {
    <p> "No files are attached to page " .. page.name; </p>
    } else {
    foreach(var file in list.sort(map.values( page.files ),'name')) {
    <p> web.link(file.uri, file.name) </p>
    }
    } edited 06:38, 30 Jun 2011
    Posted 06:38, 30 Jun 2011
    I've tried to get the "reverse" boolean in list.sort to work with no luck, so I resorted to list.reverse. Do you have an example of list.sort using the reverse boolean syntax? Thanks for the input.... and the cleaner code tip.. appreciated.
    Posted 07:27, 30 Jun 2011
    @greenbjb Take a look at: http://developer.mindtouch.com/User:SteveB/Sandbox/Files
    Posted 10:34, 30 Jun 2011
    Perfect, thanks. I'm not as good at reading syntax documentation as I used to be. ;-)
    Posted 05:50, 1 Jul 2011
    Viewing 5 of 5 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by