一个特殊的排序需求的javascript实现代码
原问题帖在这里:http://topic.csdn.net/u/20081130/09/18d455a6-65e1-4d00-aa8c-d9742654cd8c.html
排序前:"Zo","Ad","bC","dad", "bood","bada","Admin","Good","aete","cc","Ko","Beta","Could","AAA"
var t = ["Zo","Ad","bC","dad", "bood","bada","Admin","Good","aete","cc","Ko","Beta","Could","AAA"];
//var t = ['aaa','aaaa'];
function sort(arr){
for(var i=0; i0){
var tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
}
function compare(str1, str2){
/**
if(str1>str2){
return 1;
}
return 0;
**/
var r = 0;
for(var i=0, j=0; i=97) c1-=32;
if(c2>=97) c2-=32;
if(c1>c2){
return 1;
}
else if(c1str2.charCodeAt(j)){
return 1;
}
else if(str1.charCodeAt(i)
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]