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
I don't have the reputation points to comment on @mikest34 post above but @russ was correct that this callback no longer works the way it was explained.
It was Adam Cameron who discovered that when using arraySort with a callback, it no longer requires a True/False response but rather:
-1, if first parameter is "smaller" than second parameter
0, if first parameter is equal to second parameter
1, first parameter is "bigger" than second parameter
So the correct callback is:
ArraySort(yourArrayOfStructs, function(a,b) {
return compare(a.struct_date, b.struct_date);
});
Testing and working in CF2016