I have a problem - I’m trying to do Array.sortOn on an array of custom-class objects. It’s not working, though nothing in the documentation suggests that this is a problem. Below is the code. I’m confident the MetricRecord constructor is working fine because everything else works, and the traces below are correct, except they don’t sort.
Does anyone have any insight into this? I’d be very grateful.
Dave
// This array sorts
metricRecords = new Array();
metricRecords.push({mediaVehicle:“cca”, temp:“asxcvbxcber”});
metricRecords.push({mediaVehicle:“aaa”, temp:“asdfertr”});
metricRecords.push({mediaVehicle:“ttt”, temp:“asghjtryder”});
metricRecords.push({mediaVehicle:“ddd”, temp:“assdfer”});
// this array doesn’t sort
metricRecords = new Array();
metricRecords.push(new MetricRecord(15, new MetricType(), “nnnn”, “asdf”, 15, 25, 28, “notes temp”));
metricRecords.push(new MetricRecord(12, new MetricType(), “ddd”, “asdf”, 15, 25, 28, “notes temp”));
metricRecords.push(new MetricRecord(13, new MetricType(), “bbb”, “asdf”, 15, 25, 28, “notes temp”));
metricRecords.push(new MetricRecord(17, new MetricType(), “aaaa”, “asdf”, 15, 25, 28, “notes temp”));
for (i=0; i<metricRecords.length; i++){
trace("…"+metricRecords*.mediaVehicle);
}
metricRecords.sortOn(“mediaVehicle”);
trace("/////////////////////");
for (i=0; i<metricRecords.length; i++){
trace("…"+metricRecords*.mediaVehicle);
}