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
https://paxlovid.best/# paxlovid patient fact sheet
However, the most most likely theory is that it was derived from games like Chemin de
Fer.
Feel free to visit my web blog Kcnote.com
Las Vegas is a ssingle of the most popular destinations inn the US.
My web site :: san manuel online casino (May)
Hi, I do believe this is an excellent site. I stumbledupon it I am going to come back once again since I book-marked it.
Money and freedom is the best way to change, may you be
rich and continue to guide others.
Keep this going please, great job!
Nice post. I used to be checking continuously this weblog and I am impressed!
Extremely useful info particularly the final phase :
) I handle such information a lot. I used to be looking for this certain info
for a long time. Thanks and good luck.
It’s a pjty yoս don’t havе a dolnate button! I’d most certainly donate to this outstanding
blog! I suppose for now i’ll settle for book-mɑrking and aɗding your
RSS feed to mmy Googgle account. I look forward tto brand new սpdates and
will share this site ѡith my Facebook gгoup. Chat soon!
My page; camgirl squirt
Asking questions are genuinely nice thing if you are not understanding anything completely,
however this piece of writing gives good understanding yet.
Hi there, I discovered your blog by means of Google whilst searching for
a comparable matter, your site came up, it appears great.
I’ve bookmarked it in my google bookmarks.
Hi there, just turned into aware of your blog through Google, and located that
it is really informative. I am gonna watch out for brussels.
I’ll appreciate if you continue this in future.
Lots of other people will likely be benefited from
your writing. Cheers!
Lеt me introduce уou to Nutritional Products International,
а global brand management company based іn Boca Raton, FL, ᴡhich
helps domestic ɑnd international health and wellness companies launch products
in the U.S.
As senior account executive fοr business development att NPI, І ѡork ԝith many
health and weellness brands tһat are seeking to enter tһе U.S.
market օr expand their sales іn America.
After researching yoᥙr brand and product line, I wߋuld like to discuss how we can expand youг penetration in the ᴡorld’ѕ
largest consumer market.
Аt NPI, we work hard to make product launches
as easy and mooth аs posѕible. We ɑre a one-stоp, turnkey approach.
For many brands, ԝe beccome their U.Ѕ. headquarters Ƅecause we offer all tthe
services tһey need to sell products iin America. NPI ρrovides sales, logistics,
regulatory compliance, ɑnd marketing expertis to our clients.
Ꮤe import, distribute, ɑnd promote yoսr products.
NPI forr mօre thɑn a decade has helped largе and small health and wellness brands Ƅrіng theіr products tⲟ the
U.Ѕ. NPI iis yоu fast track tto The Benefits Of CBD For Your Dog
retail market.
Ϝor more information, ρlease reply t᧐ this email or contct mme at MarkS@nutricompany.ϲom.
Respectfully,
Mark
Mark Schaeffer
Senior Account Executve fⲟr Business Development
Nutritional Propducts International
150 Palmetto Park Blvd., Suife 800
Boca Raton, FL 33432
Office: 561-544-071
MarkS@nutricompany.com
Thanks for finally writing about > JS 依照元素出現數量排序 – 馬老師 雲端研究室 < Loved it!
I don’t even know how I ended up here, but I thought this post was good.
I don’t know who you are but certainly you’re going
to a famous blogger if you aren’t already Cheers!
https://stocktradestar.tumblr.com/
Great information. Lucky me I recently found your site by chance (stumbleupon).
I have bookmarked it for later!
Times Square is a single of the world’s most visited
tourist attractions, drawing an estimated 50 million visitors
annually.
Here is my page Baccarat perfume
If you are going for finest contents like me,
simply go to see this web site daily for the reason that it
gives feature contents, thanks
Thanks for sharing your thoughts about reformas integrales sant boi de llobregat.
Regards
“Dasar psikopat gila!” maki Raina menatap warna merah di atas kasur itu. sama halnya dengan Alex, Raina menenggelamkan dirinya di bawah guyuran air keran. Linangan air matanya menyatu dengan deraian air yang berjatuhan.
Hi, Neat post. Τһere’s а problеm togetһer witһ your
wweb ssite in internet explorer, ⅽould test tһis?
IE nonethelеss iѕ the market chief and a huɡe part of people ᴡill pass oѵer youг magnificent writing ɗue t᧐ thiѕ problem.
Hey There. I found your blog using msn. This is a really well written article.
I will make sure to bookmark it and return to read
more of your useful information. Thanks for the post.
I will certainly comeback.
Also, remember to shop after the festivities are over.
Effie Keily is often a mom who loves to shop with grocery
coupons that she recognized on-line. Within the “About Us” area of your site, write some good content material about who you might be.
Inexperienced buildings or typically known as eco buildings are getting well-liked, thanks mainly to the
sweeping motion to go ‘green’. Look for inexperienced
buildings and eco buildings when researching on future houses.
For a few years now, the construction of houses has grow to be much less complicated; thanks to the brand new concepts and
traits that were developed. Right now, modern house designs,
steel buildings and Islamic architectures are the rising tendencies in house construction. And with using software program and new applied sciences,
architects and engineers now discover it easy to construct personalized buildings and architectures.
Garage development can be very costly and it takes a lot of time to
construct one. If your property has no storage where you can store you car, you can all the time consider different alternate options.
On account of its durability the metallic roof can resist the issues of extreme
local weather, rain and hail, snow and robust winds are the precedence of a property owner as he considers the value
of his new roof, there’s additionally the safety from fire that is as important because the safety type the weather.
Simply because this scent is so heralded among fragrance obsessives
and novices alike, it’s really hard to get on sale.
Feel free to visit my webpage … Ali
Hi there would you mind letting me know which web host you’re working with?
I’ve loaded your blog in 3 different browsers and I must say this blog loads a lot quicker then most.
Can you recommend a good internet hosting
provider at a reasonable price? Thanks, I appreciate it!
obviously like your web-site but you have to check the spelling on several of your posts.
A number of them are rife with spelling problems and I to find it very troublesome
to tell the truth however I will definitely come again again.
It’s actually very complex in this full of activity life to listen news on TV, thus I only
use the web for that purpose, and obtain the most up-to-date news.
Thank you for another great post. The place else may
just anybody get that type of information in such an ideal way of
writing? I have a presentation subsequent week, and I’m on the look for
such info.
[url=https://radikal.host/i/gYN9v][img]https://a.radikal.host/2022/08/13/trezvod.webp[/img][/url]
Нет причины бросать свой автомобиль возле клуба или ресторана, если немного выпили.
Зачем после бурной ночи, затем утром возвращаться за машиной?
Можно просто заказать услугу трезвый водитель или обращайтесь в скайп логин pokras7777
либо в телеграмм адрес (Трезвый
водитель пенза)и мы доставим ваш автомобиль к вашему дому
Thanks for sharing your superb web site.
http://www.gazetamiedzyszkolna.pl
Nice post. I learn something totally new and challenging on websites I stumbleupon everyday.
It will always be interesting to read through content from other writers and practice a little
something from other sites.
Sweet blog! I found it while surfing around on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Appreciate it