1 varArrA = [];//create a new array of three local variables2 varARRB = [];3 varArrC = [];4 varNewcards = This. Mymahjong;//Create a new local variable equal to an array of global variables, and take the contents of the inside out and then stitch them all together.5 for(vart=0;t<newcards.length;t++){6 var Char= Newcards[t].charat (0);7 if(Char= = "a"){8 Arra.push (newcards[t]);9}Else if(Char= = "B"){Ten Arrb.push (newcards[t]); One}Else if(Char= = "C"){ A Arrc.push (newcards[t]); - } - } the varCards = []; -ArrA = Arra.sort ();//the sort () method is used to sort elements of an array. The sort order can be letters or numbers, and is sorted in ascending or descending order. The default sort order is ascending by letter. -ARRB =Arrb.sort (); -ArrC =Arrc.sort (); +Cards = Arra.concat (ARRB,ARRC);//concat () stitching three arrays in turn
The concatenation and sorting of arrays in cocos2d JS