Hi all, I have an Array called alarmQueue. I'm pushing a new arrays in to it with the contents [hours:int, minutes:int, seconds:int] and I'd like to use alarmQueue.sortOn() to sort the queue of alarms Ascending but I'm having problems getting my head around the logic.
// the function to push the alarm in to a queue
public function setAlarm(_hours:int = 0, _minutes:int = 0, _seconds:int = 0):void
{
var alarmAsArray:Array = new Array(_hours, _minutes, _seconds);
alarmQueue.push(alarmAsArray);
alarmQueue.sortOn([0, [1, 2]], Array.NUMERIC | Array.DESCENDING);
trace(alarmQueue);
}
I'm setting these alarms:
clock.setAlarm(1, 0, 31); // alarm 1
clock.setAlarm(12, 1, 21); // alarm 2
clock.setAlarm(12, 1, 19); // alarm 3
and getting the following traces:
1,0,31
12,1,21,1,0,31
12,1,21,12,1,19,1,0,31
I seem to be ordering them as: alarm 2, alarm 3, alarm 1 but I want to be ordering them by hour, then minute and seconds.
Can anyone shed any light on my sorting woes? Cheers!