I am getting an unusual error while trying to sort a Vector<String> using sort functions.
In the debugger I can see this : -
this is the code : -
// pattern = ["A10", "A2", "A5","A8", "A3", "A9","A1", "A4", "A7","A6"]
var card:Vector.<String> = pattern.slice();
card.sort(comparePatterns);
public function comparePatterns(a, b) {
var num_a:Number = Number(a.substr(1, 2));
var num_b:Number = Number(b.substr(1, 2));
// return -1, 0, or 1 depending on comparison
if (num_a < num_b) return (-1);
if (num_a == num_b) return (0);
if (num_a > num_b) return (1);
}
The code works fine 9/10 times and then I get the error : [Fault] exception, information=undefined
Can anyone help me on this ?