Hey check this out! I'm not an expert in these things, but this works. It is
only a bubble sort so it might not cope with *long* arrays.

Regards,
Matthew Walker
------



<cfset PriceList=ArrayNew(2)>

<cfset PriceList[1][1]="cabbage">
<cfset PriceList[1][2]="broccoli">
<cfset PriceList[1][3]="brussels sprout">
<cfset PriceList[1][4]="pumpkin">
<cfset PriceList[2][1]="$3">
<cfset PriceList[2][2]="$1">
<cfset PriceList[2][3]="$2">
<cfset PriceList[2][4]="$4">

<cfset Sorted = False>
<cfloop condition="Not Sorted">
    <cfset Sorted = True>
    <cfloop index="i" from="1" to="3">
        <cfset j = IncrementValue(i)>
        <cfif CompareNoCase(PriceList[1][i], PriceList[1][j]) GT 0>
            <CFSET temp = ArraySwap(PriceList[1], i, j)>
            <CFSET temp = ArraySwap(PriceList[2], i, j)>
            <cfset Sorted = False>
        </cfif>
    </cfloop>
</cfloop>

<cfoutput>
    <cfloop index="i" from="1" to="4">
        #PriceList[1][i]# #PriceList[2][i]#<br>
    </cfloop>
</cfoutput>

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to