How to reverse a list?

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default How to reverse a list?

    How to reverse a list?

    <cfset myList = "1,2,3">
    <cfoutput>
    <cfloop list="#myList#" index="theItem">
    #theItem#<br>
    </cfloop>
    </cfoutput>

    produces
    1
    2
    3

    If I want to reverse the list, can we do that?

    i.e. It prints

    3
    2
    1

    jrefactors@hotmail.com Guest

  2. Similar Questions and Discussions

    1. Reverse like query?
      I have some problems figuring this one out. How do I put together a query that selects those rows in which a field contains a substring of another...
    2. Where to get help to reverse a .W3d file?
      Last week I posted a question asking how to fastfoward and reverse a .W3d animation imported from 3ds max 6 into Director 8.5. No one answered so I...
    3. A reverse Modelunderloc?
      Is there a way of returning a 2D reference (ie on the 3d sprite) from a model in a 3d environment? Basically I want to create an 2D overlay on the...
    4. Reverse Order?
      I read a text file into HTML for viewing through a webpage, fairly straight forward. Open (INFILE, "<filename.txt") || die "Error opening...
    5. Reverse the Axis of a list box
      Doubt its possible directly. The FlexGrid control might work. But you will have to fill the rows and columns from code, not just assign a record...
  3. #2

    Default Re: How to reverse a list?

    <cfloop index="i" from="#listLen(Mylist)#" to="1" step="-1">
    <cfoutput>#ListGetAt(Mylist,i)#</cfoutput>
    </cfloop>

    <jrefactors@hotmail.com> wrote in message
    news:1129965937.431417.147410@f14g2000cwb.googlegr oups.com...
    > How to reverse a list?
    >
    > <cfset myList = "1,2,3">
    > <cfoutput>
    > <cfloop list="#myList#" index="theItem">
    > #theItem#<br>
    > </cfloop>
    > </cfoutput>
    >
    > produces
    > 1
    > 2
    > 3
    >
    > If I want to reverse the list, can we do that?
    >
    > i.e. It prints
    >
    > 3
    > 2
    > 1
    >

    George Farnsworth Guest

  4. #3

    Default Re: How to reverse a list?

    #ListSort(list, sort_type, sort_order)#


    <jrefactors@hotmail.com> wrote in message
    news:1129965937.431417.147410@f14g2000cwb.googlegr oups.com...
    > How to reverse a list?
    >
    > <cfset myList = "1,2,3">
    > <cfoutput>
    > <cfloop list="#myList#" index="theItem">
    > #theItem#<br>
    > </cfloop>
    > </cfoutput>
    >
    > produces
    > 1
    > 2
    > 3
    >
    > If I want to reverse the list, can we do that?
    >
    > i.e. It prints
    >
    > 3
    > 2
    > 1
    >

    News Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139