/ Published in: ActionScript 3

I have fixed and improved some code I found on the Internet
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public function orderAlphabetically(a, b):Number{ var pos:uint = 0; while(a[0].charCodeAt(pos) == b[0].charCodeAt(pos)){ pos++; } var num1:uint = a[0].charCodeAt(pos); var num2:uint = b[0].charCodeAt(pos); if(isNaN(num1)){ num1= 0; } if(isNaN(num2)){ num2= 0; } if(num1<num2){ return -1; }else if(num1>num2) { return 1; }else{ return 0; } }
Comments
