Multiple sort
Hi,
Would like to know is it possible to have multiple sort in array of structures
In other words,is there any equivalent function for multi_sort like in php?
For example,in the below product color information,want primary sort using product style column and secondary sort using its color. ie,if same product has different color,sort again using color as below.
AA6040~~red
KP155~~Lime
KP155~~Orange
Tried using arraySort as below,but seems it can be used to sort using single key.
<cfscript>
local.ary_styleInfo = arrayNew(1);
authors = structnew();
authors
= {
style = 'KP155'
,color = 'orange'
};
//writeDump(authors);
arrayAppend(local.ary_styleInfo ,authors);
authors = structnew();
authors
= {
style = 'KP155'
,color = 'Lime'
};
//writeDump(authors);
arrayAppend(local.ary_styleInfo ,authors);
//2
authors = structnew();
authors
= {
style = 'AA6040'
,color = 'red'
};
//writeDump(authors);
arrayAppend(local.ary_styleInfo ,authors);
writeDump( local.ary_styleInfo );
//sort
arraySort(local.ary_styleInfo, function (e1, e2){
return compare(e1.style, e2.style);
}
);
writeDump('FINAL');
writeDump( local.ary_styleInfo )
</cfscript>
