JS 依照元素出現數量排序
同樣是最近遇到的狀況,需要利用陣列內元素出現的數量進行排序,以下為範例程式:
var array = ["1", "2", "4", "5", "2", "4", "2", "3"]; var str = array.toString(); var filter = []; var result = []; document.write("原始陣列:" + array + "<br>"); var get = function (str, tar, arr, tmp) { if (str.indexOf(tar) >= 0) { tmp = str.slice(str.indexOf(tar) + 1); arr.push(tar); get(tmp, tar, arr, tmp); } return arr; } for (i in array) { var elm = []; var tmp; var fstr = filter.join(); if (fstr.indexOf(array[i]) >= 0) { continue; } else { var tmp_arr = get(str, array[i], elm, tmp); result.push(tmp_arr.length + ':' + tmp_arr[0]); filter.push(array[i]); } } result.sort(); result.reverse(); //按照出現次數排序,不刪除重複元素 var finishArray = []; for (index in result) { var show = result[index].split(':'); for (i = 0; i < show[0]; i++) { finishArray.push(show[1]); } } document.write("按出現次數排序,不刪除重複元素:" + finishArray + "<br>"); //按照出現次數排序,刪除重複元素 var finishArray = []; for (index in result) { var show = result[index].split(':'); finishArray.push(show[1]); } document.write("按出現次數排序,刪除重複元素:" + finishArray + "<br>");
輸出結果:
原始陣列:1,2,4,5,2,4,2,3 按出現次數排序,不刪除重複元素:2,2,2,4,4,5,3,1 按出現次數排序,刪除重複元素:2,4,5,3,1
Hi there! I simply wish to offer you a huge thumbs
up for the excellent info you’ve got right here on this post.
I will be returning to your blog for more soon.
purple pharmacy mexico price list mexico pharmacies prescription drugs mexican mail order pharmacies
pharmacies in mexico that ship to usa buying from online mexican pharmacy mexico drug stores pharmacies
https://www.wowonder.xyz/read-blog/18483
Woah! I’m really loving the template/theme of this blog.
It’s simple, yet effective. A lot of times it’s hard
to get that “perfect balance” between superb usability and visual appeal.
I must say you’ve done a amazing job with this. Additionally, the blog loads extremely fast for me
on Opera. Outstanding Blog!
It’s a shame you don’t have a donate button! I’d definitely
donate to this outstanding blog! I suppose for now i’ll settle for book-marking and adding your
RSS feed to my Google account. I look forward to new updates and
will share this site with my Facebook group. Talk soon!
purple pharmacy mexico price list mexican online pharmacies prescription drugs mexican mail order pharmacies
https://mexicanph.com/# mexico drug stores pharmacies
mexican rx online
Why people still use to read news papers when in this technological globe the
whole thing is accessible on net?
pronovosti.org
If some one wishes expert view regarding blogging and site-building afterward i recommend him/her to pay a quick visit this website, Keep up the fastidious work.
Fences of use miscellaneous purposes, beginning from providing safety and privacy to enhancing the aesthetics of a property. Be that as it may, like any make-up, fences press for keep, sporadic repairs, and every now parallel with replacement to ensure they extend to fulfill their intended functions. In this write-up, we’ll delve into the a sprinkling services offered not later than professional encircle companies, including shape, installation, and replacement.
Fence Patch up Services:
All over time, fences can suffer don and fly proper to out of sorts unmasking, aging, or chance damage. Base issues include warped or rotted wood, liking posts, crushed panels, loose tools, and rusted metal components. Professional bound set right services lecture these issues promptly to reimburse the rampart’s structural morality and appearance. Skilled technicians assess the bill, exhort satisfactory repairs, and efficiently carry visible the requisite work, whether it involves replacing damaged sections, reinforcing effete spots, or fixing hardware. Past addressing issues at, sidestep renewal services serve string out the lifespan of the independent and impede more widespread damage.
sidestep set right
Fence Investiture Services:
Whether you’re installing a new stonewall for barrier, sequestration, or aesthetic reasons, wizard barrier installation services ensure a hassle-free activity from start to finish. These services typically begin with a consultation to chat about the patient’s needs, preferences, and property specifications. Based on this report, experts recommend fitting enclosure materials, styles, and designs that complement the resources’s architecture and tourney the desired functionality. Knowledgeable installers treat all aspects of the ordination, from plot preparation and collection setting to panel or stake placement and unchangeable adjustments. By entrusting the burglary to experienced professionals, estate owners can ahead to a durable, fittingly installed circumscribe that enhances curb lure and land value.
Stonewall Replacement Services:
When a neutral reaches the put to death of its lifespan or sustains irreparable check compensation, replacement may be the most applied solution. Vacillating replacement services concern removing the existing fence and installing a new ditty tailored to the client’s preferences and property requirements. Professional cavil companies put forward a considerable distribute of fencing materials, including wood, vinyl, aluminum, chain-link, and composite options, allowing feature owners to on the most opportune opportunity based on durability, upkeep requirements, and budget. With scrupulous prominence to fact and importance craftsmanship, ward replacement services confirm a seamless conversion to a recent, responsible unbiased that meets the property’s needs and enhances its appeal.
Conclusion:
From repairing slight damages to installing firsthand fences and replacing worn-out structures, experienced fence services stake a crucial role in maintaining the functionality, demeanour, and value of residential and commercial properties. By partnering with wise professionals, means owners can make use of peace of mind of intellectual knowing that their fencing needs are in talented hands, ensuring long-lasting, drawing fences that act as their intended purposes effectively.
medication from mexico pharmacy reputable mexican pharmacies online mexico drug stores pharmacies
buying from online mexican pharmacy pharmacies in mexico that ship to usa mexican online pharmacies prescription drugs
buying from online mexican pharmacy reputable mexican pharmacies online mexico pharmacies prescription drugs
It’s remarkable to go to see this web page and reading
the views of all friends about this paragraph,
while I am also zealous of getting know-how.
mexican drugstore online mexican border pharmacies shipping to usa mexican pharmaceuticals online
Oh my goodness! Incredible aгticle dude! Many thanks, Howeveг I am expеriencing problems with your ᎡSS.
I don’t know the reaѕon why I can’t subscrijbe to it.
Is there anybody else getting simiⅼar RSS issues?
Anybody who knows the ѕolution can you kindly respond? Thanks!!
buying prescription drugs in mexico mexican pharmacy buying prescription drugs in mexico
mexican border pharmacies shipping to usa buying prescription drugs in mexico online mexican pharmacy
best mexican online pharmacies mexican pharmacy mexico drug stores pharmacies
pharmacies in mexico that ship to usa buying prescription drugs in mexico online pharmacies in mexico that ship to usa
Fences answer for heterogeneous purposes, beginning from providing assurance and privacy to enhancing the aesthetics of a property. However, like any structure, fences instruct keep, infrequent repairs, and then unvaried replacement to assure they extend to fulfill their intended functions. In this write-up, we’ll delve into the various services offered close to seasoned encircle companies, including repair, installation, and replacement.
Wall Mend Services:
Once again time, fences can suffer damage appropriate to out of sorts unmasking, aging, or accidental damage. Unrefined issues cover warped or rotted wood, leaning posts, crushed panels, flowing hardware, and rusted metal components. Master bound repair services lecture these issues instantaneously to reconstruct the non-partisan’s structural integrity and appearance. Skilled technicians assess the indemnity, recommend suitable repairs, and efficiently carry out the of the utmost importance commission, whether it involves replacing damaged sections, reinforcing untenable spots, or fixing hardware. Past addressing issues at, fence put services serve elongate the lifespan of the independent and impede more national damage.
enclose replacement
Divert Installation Services:
Whether you’re installing a altered fence instead of insurance, retirement, or aesthetic reasons, official fence installation services certify a hassle-free process from start to finish. These services typically begin with a consultation to chat about the shopper’s needs, preferences, and property specifications. Based on this report, experts put forward seemly independent materials, styles, and designs that quorum the resources’s architecture and chance on the desired functionality. Professional installers handle all aspects of the installation, from plot preparation and post setting to panel or stake location and unchangeable adjustments. At hand entrusting the area to experienced professionals, property owners can ahead to a long-lasting, decorously installed circumscribe that enhances contain request and property value.
Vacillating Replacement Services:
When a neutral reaches the point of its lifespan or sustains irreparable check compensation, replacement may be the most applied solution. Fence replacement services concern removing the existing wall and installing a revitalized ditty tailored to the customer’s preferences and gear requirements. Polished confine companies put forward a considerable distribute of fencing materials, including wood, vinyl, aluminum, chain-link, and composite options, allowing belongings owners to on the most applicable choice based on durability, upkeep requirements, and budget. With fussy attention to fact and quality craftsmanship, ward replacement services make safe a seamless change to a different, responsible fence that meets the property’s needs and enhances its appeal.
Conclusion:
From repairing minor damages to installing brand-new fences and replacing worn-out structures, professional encircle services play a pivotal role in maintaining the functionality, demeanour, and value of residential and commercial properties. Away partnering with experienced professionals, estate owners can take advantage of peace of do not think twice about knowing that their fencing needs are in talented hands, ensuring long-lasting, drawing fences that act as their intended purposes effectively.
purple pharmacy mexico price list mexican rx online mexican rx online
mexican mail order pharmacies reputable mexican pharmacies online best online pharmacies in mexico
I’ve been absent for some time, but now I remember why I
used to love this site. Thanks, I’ll try and check back more
frequently. How frequently you update your site?
Wonderful site. A ⅼot of usеful info here. I’m sending it to sеveral pals аns
additionally sharing іn delicious. Αnd ⅽertainly, thank you
to ʏour sweat!
Herе is mʏ web рage – lotto
Cheers, Numerous data!
viagra online canadian pharmacy canadian pharma companies prescription drugs online without
mexico drug stores pharmacies mexican pharmaceuticals online mexican mail order pharmacies
Hi there, I desire to subscribe for this webpage to take most recent updates, so where can i do it please assist.