Return to Snippet

Revision: 6621
at June 3, 2008 12:17 by ozke


Initial Code
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;
	}
}

Initial URL


Initial Description
I have fixed and improved some code I found on the Internet

Initial Title
Sort multidimensional arrays in AS3 (alphabetically)

Initial Tags
sort, array

Initial Language
ActionScript 3