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
Процесс получения диплома стоматолога: реально ли это сделать быстро?
doctorsforum.ru/viewtopic.php?f=193&t=40999
Узнайте, как безопасно купить диплом о высшем образовании
Легальная покупка диплома ПТУ с сокращенной программой обучения
samara.listbb.ru/viewtopic.php?f=3&t=668
A Trip Back In Time How People Talked About Mystery Box 20
Years Ago best online Mystery Boxes
Hi there, I check your blog like every week. Your story-telling style
is awesome, keep up the good work!
deneme bonusu veren siteler 2024: deneme bonusu veren siteler yerliarama.org – deneme bonusu veren siteler yerliarama.org
locowin slots
Hello! I know this is kinda off topic however I’d figured I’d ask.
Would you be interested in trading links or maybe guest authoring a blog
article or vice-versa? My blog goes over a lot of the same topics as yours and I feel we could greatly benefit from each other.
If you might be interested feel free to shoot me an e-mail.
I look forward to hearing from you! Fantastic blog by the way!
http://matadorbet.bid/# matadorbet.bid
deneme bonusu veren siteler denemebonusu2026.com
deneme bonusu veren siteler 2024 https://ultrabet-tr.online/# ultrabet giris
There are various tools and websites that allegation to permit users to view private
Instagram profiles, but it’s important to edit these following caution. Many of these tools can be unreliable,
may require personal information, or could violate Instagram’s terms of service.
Additionally, using such tools can compromise
your own security or lead to scams. The safest and
most ethical way to view a private profile is to send a follow
demand directly to the user. Always prioritize privacy and admiration in your online interactions.
Here is my web-site – how can you view private instagram accounts
We are a group of volunteers and starting a new scheme in our
community. Your web site offered us with valuable info to work on. You have done an impressive job and our whole community will be grateful to you.
ultrabet bonus: ultrabet – ultrabet giris
A wonderful post on JS 依照元素出現數量排序 – 馬老師 雲端研究室!
The insights you shared about Building & Property
were extremely valuable. It’s clear that you put a lot
of effort into this. Looking forward to reading
more of your work. Keep up the great work!
guvenilir casino siteleri Canl? Casino Siteleri Casino Siteleri
en kazancl? slot oyunlar?: slot oyunlar? puf noktalar? – slot oyunlar?
Yes. Therе are no restrictions on whho can theoretically join Arsenal’ѕ academy, but
it ⅾoes of couгsе provide that you аre goⲟd enough
for them to᧐ offer you a spot and that you can obtain a permit for
living in thе UK.
Feell free to visit my website; ดอกไม้ไว้อาลัย ต่างประเทศ
https://casinositeleri.win/# casino siteleri win
deneme bonusu veren siteler betturkey
I think what you published made a bunch of sense. However, what about this?
suppose you composed a catchier title? I ain’t saying your information isn’t
solid, however suppose you added a headline
to possibly grab a person’s attention? I mean JS 依照元素出現數量排序 –
馬老師 雲端研究室 is kinda boring. You should look
at Yahoo’s front page and watch how they write news titles to grab people to open the
links. You might add a video or a related picture or two to get readers excited about what you’ve got to say.
In my opinion, it would make your posts a little livelier.
Triangle Blliards & Bar Stools
1471 Niswon Ꭱd, Tustin,
СΑ 92780, United Ⴝtates
+17147715380
Buy Pool Table Equipment
Как не стать жертвой мошенников при покупке диплома о среднем полном образовании
files.4adm.ru/viewtopic.php?f=2&t=803
Your way of telling all in this article is really nice, all be able to without difficulty understand it, Thanks a
lot https://en.poupartsyndic.ca/
https://casinositeleri.win/# Deneme Bonusu Veren Siteler
denemebonusuverensiteler.top
The Reasons To Focus On Improving Fridge Freezer French Doors Uk vinterkall french Door Fridge/freezer review
The 10 Most Terrifying Things About Folding Scooters Heavy Duty electric mobility scooter
ultrabet giris ultrabet bonus ultrabet tr online
deneme bonusu veren siteler betturkey betturkey.com https://slot-tr.online/# en kazancl? slot oyunlar?
Can you tell us more about this? I’d like to find
out some additional information.
https://w1.prediksinagasaon.cfd/
Since the admin of this website is working, no doubt very soon it
will be famous, due to its quality contents.
I every time used to read piece of writing in news papers
but now as I am a user of net thus from now I am using
net for posts, thanks to web.