Here is a bubble sort I wrote the other day to sort a 2d array. It should
be fast enough, unless you are sorting 1000s and 1000s of records.
<cfscript>
for (x = 1; x lte ArrayLen(reportArray); x = x + 1) {
for (y = 1; y lt ArrayLen(reportArray); y = y + 1) {
// if the earlier score is less than the later, swap them
if (reportArray[y][2] lt reportArray[y+1][2]) {
temp1 = reportArray[y][1];
temp2 = reportArray[y][2];
reportArray[y][1] = reportArray[y+1][1];
reportArray[y][2] = reportArray[y+1][2];
reportArray[y+1][1] = temp1;
reportArray[y+1][2] = temp2;
}
}
}
</cfscript>
Dana Larose
ColdFusion Monkey
Canadian Web Design & Consulting Inc.
A: 701-281 McDermot Avenue (McDermot & King)
P: 204.946.5155
C: 204.228.0477
F: 204.946.5156
E: [EMAIL PROTECTED]
W: http://www.cdnwebdesign.com
------------------------------------------------------------------------------
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.