[thelist] ColdFusion - 2 dimensional array sort

Joshua OIson joshua at alphashop.net
Sat May 26 17:43:53 CDT 2001

You could handcode a sorting algorithm and apply it to your arrays:




Other people have implemented this using a struct instead of an array and
apply the structsort method.  Here's a siplet from the help file:

StructSort(Base [, PathToSubElement, SortOrder, SortType])

StructSort was added in ColdFusion 4.5.1, SP2. StructSort returns an array
of structures containing top-level key names (strings) sorted according to
the value of the specified sub-element. The value of the keys may be simple
values or complex elements.

A ColdFusion struct with one field (an associative array).

Specifies the path to apply to each of the top-level keys in order to reach
the element whose value you wish to sort by. If unspecified,
PathToSubElement, defaults to nothing: meaning that the top-level entries
will be sorted based on their own values.

SortOrder may be "ASC" (ascending) or "DESC" (descending). The default is

SortType may be "NUMERIC", "TEXT", or "TEXTNOCASE". The default is "TEXT."

The PathToSubElement string does not support array notation so only
substructures of structures are supported.

Good luck,

----- Original Message -----
From: "jon steele" <jjsteele22 at yahoo.com>

: Now I want to sort the array using the first element in the second
: "dimension" (if that's what you call it)... that is, using the numeric
: value. So the output when looping throught is this:

More information about the thelist mailing list