Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Sorting a Structure

    I must be missing something as I can't seem to figure out how to sort
    a structure based on the key name, not key value. I'm trying to create a
    universal email cfc that will take the fields submitted via a form and
    generate an email. The problem is the email isn't returning the values
    in the desired order. I have added extra letters/numbers to the
    beginning of the form names and tried using the structSort function but
    it still doesn't work. For example I have tried using A-First_Name,
    B-Last_Name, etc., as well as, 1-First_Name, 2-Last_Name, etc. Any ideas?

    Here is the base code:
    <cfif isDefined("arguments.submit")>
    <cfset structDelete(arguments,"submit")>
    </cfif>
    <cfif isDefined("arguments.fieldnames")>
    <cfset structDelete(arguments,"fieldnames")>
    </cfif>
    <cfmail to="emailAddress" from="#arguments.name# <#arguments.email#>"
    subject="#arguments.subject#">
    <cfset structDelete(arguments,"subject")>
    <cfloop collection="#arguments#" item="keyValue">
    #replace(keyValue,"_"," ","all")#: #structFind(arguments,keyValue)#
    </cfloop>
    </cfmail>

    Thanks in advance.

    --
    Bryan Ashcraft (remove brain to reply)
    Macromedia Certified Dreamweaver Developer
    Paragon Visuals :: [url]http://www.paragonvisuals.com[/url]
    TMM Volunteer (DW) :: [url]http://www.macromedia.com/go/team/[/url]
    ~~~~~~~~~~~~~~~~~~~~~~~~
    Got Questions? Get Answers
    DWFAQ :: [url]http://www.dwfaq.com[/url]
    PVII :: [url]http://www.projectseven.com/go/[/url]
    --
    Bryan Ashcraft ::TMM:: Guest

  2. Similar Questions and Discussions

    1. Sorting array vs sorting paginated array
      ....pulling in a long list of photos in a gallery, and I have a sort function working within the pages of data fine. I need to bring it back out of...
    2. Class::Struct - want to access structure within structure
      I want to access a structure within a structure. Below is what I had in mind. Please help. #!/perl/bin/perl use Class::Struct; struct Step...
    3. Add to Structure
      I'm a structures newbie. I need to know how to 1) Determine if a structure already exists 2) If not, create it. If yes, add to it. I've got...
    4. Sorting an Array containing a structure...
      I a loop nested in a loop that drives a query that kind of walks backwards out by a commodity classification then by region classification... so...
    5. W3D structure...
      Hi My big problem is that I have some deformations that are already defined by vertices index, and their moves... But these deformations are...
  3. #2

    Default Re: Sorting a Structure

    You could do something like...



    <cfloop list="#ListSort(StructKeyList(arguments), "text", "ASC")#" index="keyValue">
    #replace(keyValue,"_"," ","all")#: #arguments[keyValue]#
    </cfloop>
    BSterner Guest

  4. #3

    Thumbs up Re: Sorting a Structure

    1. Use structKeyArray() to create an array of the struct keys

    2. User arraySort() to sort the array

    3. You can then use a cfloop to loop through the array and reference the struct on each loop
    Jay 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