I have an array of structs in ColdFusion. I\'d like to sort this array based on one of the attributes in the structs. How can I achieve this? I\'ve found the StructSort fun
Here is something that closely resembles the original StructSort(). It also supports the pathToSubElement argument.
StructSort()
pathToSubElement
Usage / test:
arr = ArrayNew(1); for (i = 1; i lte 5; i = i + 1) { s = StructNew(); s.a.b = 6 - i; ArrayAppend(arr, s); }
Result: