After reading it, 1 is a hand itch, 2 is to think there is a problem with the implementation of the landlord, just write it, with js, it took about 30-40 minutes. Original question post here: http://topic.csdn.net/u/20081130/09/18d455a6-65e1-4d00-aa8c-d9742654cd8c.html
Before sorting: "Zo", "Ad", "bC", "dad", "bood", "bada", "Admin", "Good", "aete ", "cc", "Ko", "Beta", "cocould", "AAA" <script type = "text/javascript"> var t = ["Zo ", "Ad", "bC", "dad", "bood", "bada", "Admin", "Good", "aete", "cc", "Ko ", "Beta", "cocould", "AAA"]; // var t = ['aaa', 'aaa']; 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) {re Turn 1;} return 0; **/var r = 0; for (var I = 0, j = 0; I <str1.length & j <str2.length; I ++, j ++) {status = 'I =' + I + 'J = '+ j; var c1 = str1.charCodeAt (I); var c2 = str2.charCodeAt (j ); if (c1> = 97) c1-= 32; if (c2> = 97) c2-= 32; if (c1> c2) {return 1 ;} else if (c1 <c2) {return 0;} else if (c1 = c2) {if (str1.charCodeAt (I)> str2.charCodeAt (j) {return 1 ;} else if (str1.charCodeAt (I) <str2.charCodeAt (j) {return 0 ;} Else if (str1.charCodeAt (I) = str2.charCodeAt (j) {continue ;}} if (I! = Str1.length) {return 1;} else if (j! = Str2.length) {return 0 ;}} sort (t); alert ("sorted:" + t); script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]