The
makes a record, mainly on the processing of numbers, and if the preceding characters are the same, the numbers are compared by values rather than by individual characters.
function Sortlikewin (v1, v2) {var a = V1.name; var b = v2.name; var reg =/[0-9]+/g; var lista = A.match (reg); var Listb
= B.match (reg); if (!lista | |!listb) {return a.localecompare (b);} for (var i = 0, Minlen = math.min (Lista.length, listb.length); ; Minlen; i++) {//numeric location ordinal var indexa = A.indexof (Lista[i]); var indexb = B.indexof (listb[i));//number preceding prefix var Prefixa = a.substring (
0, Indexa);
var prefixb = a.substring (0, INDEXB);
string var stra = lista[i] of numbers;
var strb = listb[i];
The value of the number var Numa = parseint (stra);
var numb = parseint (STRB); If the numbers are unequal or prefixed with different prefixes, they are compared directly to the IF (indexa!= indexb | | Prefixa!= PREFIXB) {return a.localecompare (b);} else {//number str ing equality if (stra = = STRB) {//If the last digit, compare the suffix of the number if (i = = minLen-1) {return a.substring (indexa). Localecompare (b.substring
(INDEXB));
//If not the last number, the loop jumps to the next number and removes the same part else {a = a.substring (Indexa + stra.length); b = b.substring (Indexa + stra.length); }//If the number string is not congruent, but the value is equal else if (numa = = numb) {//Direct comparison of the number prefix 0Number, more small return strb.lastindexof (numb + ')-stra.lastindexof (Numa + ');
else {//If number is not equal, direct comparison number size return Numa-numb}} }
}
Use method, Array.Sort (Sortlikewin);
The above mentioned is a small set of JS simulation based on the Windows file according to name sorting effect, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!