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
How How Much Does It Cost To Replace A Porsche Key Became The Top Trend On Social Media Porsche Key Price
Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт бытовой техники
gay porn
online order medicine: america rx pharmacy – indian pharmacy paypal
10 Facts About Futon Sleeper Sofa That Can Instantly Put You In A Positive Mood Modern Sleepers
ретрит где пройти https://ретриты.рф
A Time-Travelling Journey: How People Talked About Mental
Health Assessment London 20 Years Ago mental health Assessment online test [https://hikvisiondb.webcam]
How To Resolve Issues With Gspot Vibrator g spot vibrators
Wild Casino: Wild Casino’s impressive 600+ casino game offering, daily tournaments, and massive $9,000 crypto welcome package make it an excellent choice for blockchain enthusiasts. There are many real money casino games to choose from, including online roulette, baccarat, craps, blackjack, and live dealer games. Still, slots are the most popular games at top real money casinos, and you’ll find hundreds of them on offer at the best sites. In this blog, we will talk about how these casino bonuses work, what kinds you might see, and some tips on how to use them smartly. We’ll examine whether you can make money from these bonuses and what you should watch out for. It’s all about having fun and getting a little extra, but in a way that’s easy to understand. You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.
http://sungkyuljaega.com/bbs/board.php?bo_table=free&wr_id=173129
Poker Squares Scoring in Solitaire City. Since my 24th birthday is just around the corner (feb 11th), I decided to open up the festivities with a brand new Solitaire Card Game–Poker Solitaire! Action & excitement galore—WSOP is the king of social, free-to-play poker games! You can, apparently, win Balatro by making it to the end of the eighth round of matches. I found this out by Googling the question and coming a cross a Steam forum thread where some braggart claimed to have won it on their second round, and continues to win 80% of the time. I hate this person. Build multiple Poker hands to score 150 points or more. Our Spider Solitaire game has 3 levels: 1 colour (easy), 2 colours (more challenging), and 4 colours (extremely challenging, only for the real expert). Level 1 is played differently from the other two levels:
Pretty element of content. I simply stumbled upon your weblog and in accession capital to say that I get in fact loved account your weblog posts.
Any way I’ll be subscribing on your augment
and even I achievement you get entry to persistently
rapidly.
What Is Best Chest Freezer For Garage Uk And Why
Are We Talking About It? Lg electronics Fridge
You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page. There were also success stories on Day 1a, including from none other than Gold, who managed to chip up nicely throughout the day as he battled in the Silver section of Horseshoe. Poker coach Faraz Jaka, meanwhile, got well above starting stack after picking up aces to eliminate Tyler Matzen. The weekly reload bonus can reach 90%. The first step to getting this bonus is to climb up to level 10 of the loyalty program. After you have opted in the promotion, you will need to activate the bonus from the “Bonuses” section on the site. We will then ask you to deposit at least $ €30, and the bonus cash will be yours! Moreover, the members of the Vulkan Vegas VIP club (starting from the Luxor level) are eligible for a weekly cashback of 3%-12%, up to 2,000 USD EUR.
https://israelxbba863185.aioblogs.com/82537888/fair-go-casino-no-deposit-bonus
PayForIt is a digital payment method that allows players to use their mobile phone credit to pay for different services throughout the United Kingdom. If your mobile phone has data, Wi-Fi, and a sim card, users from Three, Vodaphone, O2, EE, Virgin, and Tesco mobile can use their phone bill as payment. At a casino Payforit really is one of the best depositing options, as you’ll know if you’ve read through this entire page. This is because it is incredibly secure, plus it also allows you to deposit quickly and without any hassle. You’ll find that you can use Payforit to deposit at a huge range of casinos in the UK, and this number is only continuing to go up. When it comes to playing at a mobile casino Payforit really is an option you should strongly consider.
It Is The History Of Fiat 500 Key In 10 Milestones remote
24 hour pharmacy: cialis singapore pharmacy – the drug store pharmacy columbus ohio
The 10 Most Terrifying Things About Mitsubishi Key Programmer mitsubishi key programmer
(Dante)
капельница от запоя на дому капельница от запоя на дому .
super saver pharmacy: top rx pharmacy – legal online pharmacies in the us
12 Companies That Are Leading The Way In Diagnosing Adult ADHD getting an adhd diagnosis uk
Thanks a bunch for sharing this with all of us you really
recognize what you’re talking about! Bookmarked.
Please also discuss with my web site =). We could have
a hyperlink change contract between us
Five Killer Quora Answers To Link Togel Resmi Link Togel
This Is The New Big Thing In Electric Wall.Mounted
Fire White Electric Wall Mounted Fire
Bunk Beds L Shape: The Good, The Bad, And The Ugly
l shaped bunk bed with wardrobe
online pharmacy viagra us: viagra local pharmacy – new zealand pharmacy domperidone
cialis super active online pharmacy: online pharmacy no prescription lasix – finasteride indian pharmacy
ретрит туры для мужчин https://ретриты.рф
20 Things You Should Be Educated About Emergency Auto Locksmith Near Me automotive locksmith near me prices (Nicole)
clozaril registry pharmacy: viagra pharmacy prices – in store pharmacy
Guide To Treadmill Used For Sale: The Intermediate Guide Towards Treadmill Used For Sale treadmill used for sale; 1071gru.xida.ru,
대구 1등 보도알바 사무실입니다. 대구 보도사무실에서 같이 돈 벌어 가시죠.
7 Simple Tricks To Rocking Your Electric Incline Treadmill electric treadmill 300 lb capacity
(Inez)