Skip to main content
Known Participant
December 7, 2009
Question

Reorder an Array

  • December 7, 2009
  • 3 replies
  • 795 views


I have built an array like so


<cfset ABCArray = Arraynew(1)>
<cfset i = 0>
<cfloop query="ABC_Dates">
    <cfset i = i + 1>
    <cfset ABCArray=StructNew()>
    <cfset ABCArray.project = project>
    <cfset ABCArray.cdeyear = #getYear()#>
    <cfset ABCArray.event_date = #displayDate()#>
    <cfset ABCArray.event_date = #displayregDate#>
</cfloop>

So in the CFLOOP I want to be able to compare the current date to the event date and move the item to end of the array if it has passed so that the next upcoming event is on top.  Does any know how to do this ? A code example would be great. Thanks.

    This topic has been closed for replies.

    3 replies

    Known Participant
    December 7, 2009

    Can you call a function from a CFLOOP?

    Inspiring
    December 7, 2009

    You can, but it's a better idea to call it after the loop has finished.

    Inspiring
    December 7, 2009

    Try the ArrayOfStructsSort function cflib.org. It shows how to sort an array of structures.

    http://www.cflib.org/udf/ArrayOfStructsSort

    Inspiring
    December 7, 2009

    (Not sure if this can help you or not..)

    Try passing your array to this UDF..

    http://cflib.org/udf/sortArrayOfStructures

    HTH

    Inspiring
    December 7, 2009

    http://cflib.org/udf/sortArrayOfStructures

    Well .. at least there is no shortage of options.

    -Leigh

    Inspiring
    December 7, 2009

    Yes Leigh....