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
We’re a ɡroup of volunteers and starting a new scheme in our community.
Your web site offered us with valuable info to work on. You һave Ԁone a formidable job and
our whole community wilⅼ be thaqnkful to yߋu.
Our reside webcam chat will fulfill your sexual requires at any
time mainly because we provide a free and protected chat provider for these
who are on the lookout for an best adult chat rooms conversation with
a cam. They’re all looking for another person they can masturbate with and orgasm on webcam.
Chat Live on webcam with Asian, Ebony, Latina, Indian and Eastern European beauties!
ChatRandom blends text and movie chat with simplicity – as you are on-phone with somebody,
you can mail them a message! Don’t fret, you
are going to enjoy a 50 % price cut if you’re a new member.
If you are fatigued of sending messages to ladies who hardly ever respond and want a truly interactive hookup experience, FapChat is for you.
Michael Pratt, Matthew Wolfe and Andre Garcia generally used aliases when dealing with the women they recruited
and never disclosed their authentic names. Wallis’ solid standing in Hollywood frequently helped safe some
of the greater names for Elvis’ motion pictures, and this movie was no exception. That said,
our leading picks arrive with solid safety options to shield your economical
and personal data versus any third get-togethers lurking across the web.
It was discovered by scientists in the subject of data protection that
Microsoft Edge sends persistent identifiers that can be
utilised to url requests (and affiliated IP addresses/destinations) to
backend servers.
Hey! Someone in my Facebook group shared this website
with us so I came to look it over. I’m definitely loving the information. I’m book-marking
and will be tweeting this to my followers!
Terrific blog and fantastic design and style.
лучшие сериалы онлайн бесплатно
Other people will appreciate and benefit from your experiences
and insights. You only have one choice to make
if you want to keep that cash in your pocket. You can get what is called a payday loan or cash advance to
help you get out of a jam.
Hellߋ colleɑgues, fastidious paragraph
annd fastidious arguments commented at thiѕ placе, I am genuineⅼy enjoying by these.
Great beat ! I would like to apprentice while you
amend your web site, how can i subscribe for a blog site?
The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea
My webpage; mn junk yard
This design is steller! You definitely know how to keep a reader amused.
Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
I really enjoyed what you had to say, and more than that, how
you presented it. Too cool!
Wonderful web site. Lots of useful information here.
I am sending it to some pals ans also sharing in delicious.
And naturally, thank you to your effort!
Heya i’m for the first time here. I came across this board and I in finding
It truly useful & it helped me out a lot. I am hoping to provide something back
and help others such as you helped me.
We are a bunch of volunteers and starting a new scheme in our community.
Your website provided us with helpful info to work on. You have done an impressive task and our whole neighborhood can be grateful
to you.
What’s up Dear, are you actually visiting this site daily, if so then you will without doubt get fastidious experience.
bookmarked!!, I really like your website!
Here is my web blog; zalayeta02
Fences answer for different purposes, beginning from providing protection and privacy to enhancing the aesthetics of a property. In what way, like any structure, fences instruct sustention, periodic repairs, and sometimes parallel with replacement to ensure they continue to fulfill their intended functions. In this article, we’ll delve into the various services offered about professional fence companies, including patch, coronation, and replacement.
Non-aligned Condition Services:
Over days, fences can suffer injury due to weather hazard, aging, or unlucky damage. Average issues subsume partiality or rotted wood, tendency posts, broken panels, loose hardware, and rusted metal components. Master bound set right services talk to these issues speedily to reimburse the vacillating’s structural morality and appearance. Skilled technicians assess the damage, propose acceptable repairs, and efficiently effect over the of the utmost importance work, whether it involves replacing damaged sections, reinforcing rickety spots, or fixing hardware. By addressing issues at the crack, impartial put services help elongate the lifespan of the irresolute and impede more extensive damage.
hedge shape
Separate Installation Services:
Whether you’re installing a modish fence in place of security, sequestration, or aesthetic reasons, qualified rampart fitting services certify a hassle-free convert from start to finish. These services typically begin with a consultation to debate the client’s needs, preferences, and mark specifications. Based on this report, experts counsel fitting shilly-shally materials, styles, and designs that complement the land’s architecture and chance on the desired functionality. Professional installers handle all aspects of the ordination, from put preparation and delivery milieu to panel or observer placement and final adjustments. During entrusting the job to knowing professionals, assets owners can expect a long-lasting, decorously installed circumscribe that enhances restraint request and property value.
Bound Replacement Services:
When a bound reaches the put to death of its lifespan or sustains irreparable impairment, replacement may be the most efficient solution. Confine replacement services concern removing the existing wall and installing a untrodden ditty tailored to the customer’s preferences and belongings requirements. Expert confine companies put forward a deviating cooking- stove of fencing materials, including wood, vinyl, aluminum, chain-link, and composite options, allowing estate owners to settle upon the most suitable choice based on durability, upkeep requirements, and budget. With scrupulous acclaim to detail and importance craftsmanship, fence replacement services confirm a seamless conversion to a new, principled circumscribe that meets the idiosyncrasy’s needs and enhances its appeal.
Conclusion:
From repairing negligible damages to installing brand-new fences and replacing worn-out structures, licensed encircle services play a pivotal r“le in maintaining the functionality, demeanour, and value of residential and commercial properties. By partnering with wise professionals, estate owners can fancy peacefulness of do not think twice about knowing that their fencing needs are in capable hands, ensuring long-lasting, drawing fences that be serviceable as their intended purposes effectively.
What’s up to every one, it’s in fact a pleasant for me to
pay a quick visit this website, it consists of precious Information.
Have you ever thought about including a little bit more than just your
articles? I mean, what you say is fundamental and all.
Nevertheless think of if you added some great graphics or videos to give your posts more, “pop”!
Your content is excellent but with images and clips,
this site could certainly be one of the very best in its field.
Awesome blog!
Fences answer for disparate purposes, starting from providing security and monasticism to enhancing the beauty of a property. Be that as it may, like any structure, fences press for upkeep, periodic repairs, and sometimes unvaried replacement to ensure they persist to fulfill their intended functions. In this piece, we’ll delve into the several services offered not later than skilled fence companies, including repair, institution, and replacement.
Wall Repair Services:
All over days, fences can suffer injury due to brave risk, aging, or unlucky damage. Unrefined issues cover perverse or rotted wood, tendency posts, disintegrated panels, let go tools, and rusted metal components. Professional hold at bay mend services address these issues right away to resuscitate the rampart’s structural integrity and appearance. Skilled technicians assess the indemnity, exhort acceptable repairs, and efficiently effect excuse the requisite calling, whether it involves replacing damaged sections, reinforcing effete spots, or fixing hardware. Close to addressing issues near the start, sidestep repair services alleviate elongate the lifespan of the fence and intercept more extensive damage.
get by instatement
Vacillate Investiture Services:
Whether you’re installing a new fence instead of protection, retirement, or aesthetic reasons, professional barrier placement services ensure a hassle-free procedure from start to finish. These services typically set out on with a consultation to discuss the shopper’s needs, preferences, and worth specifications. Based on this facts, experts advise fitting enclosure materials, styles, and designs that quorum the land’s architecture and chance on the desired functionality. Experienced installers treat all aspects of the induction, from site preparation and dispatch setting to panel or stake location and unchangeable adjustments. At hand entrusting the burglary to wise professionals, property owners can wait for a firm, suitably installed fence that enhances curb lure and land value.
Bound Replacement Services:
When a fence reaches the d‚nouement of its lifespan or sustains irreparable check compensation, replacement may be the most practical solution. Vacillating replacement services subsume removing the existing hedge and installing a new one tailored to the patient’s preferences and gear requirements. Professional confine companies offer a considerable distribute of fencing materials, including wood, vinyl, aluminum, chain-link, and composite options, allowing feature owners to on the most suitable choice based on durability, maintenance requirements, and budget. With fussy regard to fact and rank craftsmanship, impartial replacement services ensure a seamless transformation to a new, reliable unbiased that meets the idiosyncrasy’s needs and enhances its appeal.
Conclusion:
From repairing slight damages to installing brand-new fences and replacing worn-out structures, experienced encircle services play a pivotal place in maintaining the functionality, demeanour, and value of residential and commercial properties. Away partnering with knowing professionals, land owners can make use of peace of intellectual private that their fencing needs are in apt hands, ensuring long-lasting, good-looking fences that be in the service of their intended purposes effectively.
https://canadianinternationalpharmacy.pro/# trusted canadian pharmacy
https://medicinefromindia.store/# indian pharmacy
I’m extremely pleased to discover this page. I wanted to thank
you for ones time for this particularly wonderful read!!
I definitely appreciated every bit of it and I have
you bookmarked to check out new things in your blog.
The controversial social media character and former kickboxer, 36,
was arrested on Thursday alongside his brother Tristan, 34, and two Romanian ladies on suspicion of human trafficking, rape and forming an organised crime group.
Russell says that strong unions additionally provide a guaranteed safety
web, giving unemployment advantages for up to two years.
Federal regulation requires importers and manufacturers to test numerous
consumer merchandise for compliance with client product security necessities.
While biking by the city, following a lovely historical and naturalistic route, it will likely be doable to taste among
the native eno-gastronomic merchandise. Stimulate
the thoughts and your temper will lighten. The situations
he will face behind bars on the Bucharest Police Detention Centre
are a far cry from these of the excessive-rolling life-style he claims to take
pleasure in. Andrew Tate will ring in the new Year
in a Romanian jail cell as investigators look into claims he saved
six women underneath house arrest ‘like prisoners’ is complete,
a court determined.
my blog post – Best webcam Sites
buy erection pills pills for erection best pills for ed
TikTok++’ın özellikleri arasında video indirme, video paylaşma ve gizli mod gibi özellikler yer alır.
Please let me ҝnow if you’re looking for a author for your blog.
You һave some rгeally great ɑrtiсles and
I think I ѡould ƅe a good asset. If you ever want tto ake some of the load off,
I’d love to write some articles for your bkog in exchange for a
link Ƅƅack to mine. Pleɑse blast mee an e-mail if inteгested.
Thanks!
Feeel free to sսrf tto my weeb page; gacor
Hi, yeah this article is in fact fastidious and I have learned lot of things from it regarding blogging.
thanks.
mexico pharmacy buying from online mexican pharmacy mexican pharmacy
top 10 pharmacies in india: cheapest online pharmacy india – best online pharmacy india
http://edwithoutdoctorprescription.pro/# buy prescription drugs online legally
Hеllo to every one, the contents existing at this
website are really amazing for ρeople knowledge, well,
keep up the good work fellows.
Also viѕit my page :: ProxyDiscount.com
Antes de baixar video do instagram qualquer vídeo do Instagram, pergunte primeiro ao autor
do conteúdo.