The concatenation and sorting of arrays in cocos2d JS

Source: Internet
Author: User



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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.