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
Thanks for some other informative blog. The place else may I
get that kind of info written in such a perfect approach?
I’ve a challenge that I am just now running on, and I have been at
the glance out for such info.
Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт цифровой техники челябинск
I am actually delighted to read this weblog posts which
consists of lots of useful data, thanks for providing such information.
aⅼl the time i used to read smaller articles wһіch
as ԝell clеar theіr motive, and that iѕ also happening ԝith tһiѕ
piece of writing ԝhich Ӏ aam reading at thiss tіme.
Also visit mу site … Global events
15 Best Robot Vacuum With Lidar Bloggers You Need To Follow Best robot vacuum with lidar
Excellent, what a weblog it is! This web site gives valuable information to us, keep it up.
What Is Adult Diagnosis Of ADHD And Why Is Everyone Talking About It?
diagnosing adhd (mdit.kr)
I am sure this post has touched all the internet users, its really really pleasant article on building up new webpage.
капельница от запоя стоимость капельница от запоя стоимость .
Pogo is a platform that hosts many different online games. It is basically the mecca for online games for long distance couples! Once you make an account on Pogo, you’ll have access to classic games such as Scrabble, Monopoly, Cribbage, Battleship, Chess, Bingo, Yahtzee, Risk, and more. Virtual teams need opportunities for team building if they want to stay engaged in their work and grow in their skills. Online team building games are productive and fun solutions to keeping your employees happy at work and invested in your company. Keep reading to get the know-how on free and fun online team building games! Any Android game or software can be distributed through Google Play. Three simple actions are required to get the multiplayer social bingo game into the Android Playstore. One of the best-known bingo platforms is the Online Bingo Software, allowing users to play Bingo online.
https://progresspond.com/members/scenalseho1971/
This page presents the most up-to-date top 100 online casinos UK list, plus a few more that are included for excellence in specific criteria. However, there are many others that didn’t make the cut. This is because we rate all online casinos via a comprehensive review process. To calculate an overall rating out of 100, we score each casino site out of 10 for each of the following categories: The Mecca Games promo page is overflowing with a variety of casino and slot promotions, bonuses and deals for you to top up your bonus balance. Enjoy a casino bonus as soon as you make your first deposit, as our way of saying welcome to Mecca Games! Minimum 5 pound deposit casino sites newukcasino.uk *18+. New Players only. Up to 50 (15p) free spins (FS) locked to Bonus Money Spins. Win paid as bonus credit. 40x wagering requirement on FS and bonuses. 7 day expiry. £50 max withdrawal from bonuses without a deposit across all Intouch Games Accounts; mFortune, Mr Spin, Dr Slot, PocketWin, Casino2020, Cashmo, Bonus Boss, Jammy Monkey. Up to 100% deposit match of first deposit awarded as bonus credit via lobby game. Max bonus £100. Min deposit £3. 30 days to claim for deposit match. 7 day expiry. T&Cs apply. BeGambleAware.org. #AD
Wow that was strange. I just wrote an really long comment but after I
clicked submit my comment didn’t appear. Grrrr…
well I’m not writing all that over again. Regardless, just wanted to
say excellent blog!
How Can A Weekly Assessment Adult Adhd Project Can Change Your
Life Adhd Assessment For Adults Leicester
people’s pharmacy prozac: non prescription medicine pharmacy – viagra price pharmacy
corner drug store: online pharmacy flovent inhaler – correct rx pharmacy
Appreciating the commitment you put into your site and
in depth information you offer. It’s awesome to come across a blog every
once in a while that isn’t the same outdated rehashed material.
Wonderful read! I’ve saved your site and I’m including your RSS feeds to my Google account.
bradleys pharmacy artane: prescriptions online pharmacy – viagra utah pharmacy
This Is The Advanced Guide To New Nissan Key nissan Car key replacement Price
капельницы от запоя капельницы от запоя .
капельница от запоя стоимость капельница от запоя стоимость .
Live! Casino & Hotel Maryland If you are a WordPress user with administrative privileges on this site, please enter your email address in the box below and click “Send”. You will then receive an email that helps you regain access. $500 Million Casino Project Opens to Huge Crowds, Boosts Local Economy and Introduces a New Class of Gaming and Entertainment to the Mid-Atlantic Gaming Region Baltimore Fishbowl The Hall At Live! Casino Powered by Hotels This cutting-edge sports bar concept has a proven track record as Live! has opened similar venues in Atlanta, St. Louis, Texas, Pittsburg and Philadelphia. The design, décor and technology that has been integrated into Sports & Social did not come cheap at a cost of $15 million. The new venue will create over 100 new jobs which will provide additional stimulus to push the economic recovery forward.
https://ckan.apps-teste.ufvjm.edu.br/user/garbpersglucet1984
Stardust Casino Las Vegas | Online games in online casinos 2020 As Temple Slots Casino accepts players from multiple countries, they offer a substantial range of popular banking options specific to their players’ region. Depending on which countries players are from, their native banking services will auto-populate on-screen when choosing to make a deposit or withdrawal at Temple Slots Casino. Several of these payment methods that are available across the board include MasterCard and Visa, Paysafecard, Electronic Wire Transfers and eWallet’s like Skrill and Neteller. Gods Temple slot has 6 reels as well as 64 pay lines video online slot machine, launched in 2016. Surely, game must be labeled as new but reliable. Aztec Temple is one of the older titles developed by Platipus and as its name implies, it portrays Aztec civilization. Fans of this thematic will no doubt be pleased with the level of detail the software provider has implemented into the graphics style. Visually, Aztec Temple looks both appealing and minimalistic, allowing you simply take in the graphics. As far as gameplay is concerned, this game comes with 5 reels and 20 different paylines, a mostly traditional setup. Moreover, the betting limits make this game accessible to both casual players and mid-rollers, permitting wagers between $0.20 and $40 per spin.
What feels wonderful just one week may perhaps be uncomfortable the up coming. They turn out to be a lot more intense and agitated, suggestions and views on increasing the spirit and is a time when the intellect can grow to be obsessed with 1 assumed, devoid of the skill to discriminate in between superior and negative. You will have to balance things in your lifetime, but with the appropriate companion and guidance procedure, you can accomplish regardless of what you established out to do. In specific, the asanas as a shoulder support, fish are the backbone and turned to aid harmony the endocrine procedure. In individual, the working of the thyroid and adrenal glands are important simply because they are controlled by a wide variety of feelings, moods and anxiety on the human human body. Regular follow of yoga will also assistance you be less vulnerable to worry and you will come across that your days are a lot more stress free of charge. Previous Month Casino Bonuses are not easy to find on the web. Even if you are a newbie, you will obtain that meditation calms the turmoil in your brain. Cuba enables adoption by exact-intercourse marriages (given that September 2022 referendum) and different-sex marriages, and even by solitary people. September 2007 was a rough thirty day period for Clinton’s fundraising strategy.
How A Weekly Adhd Symptoms In Women Test Project Can Change Your
Life main symptoms of Adhd
Если вы искали где отремонтировать сломаную технику, обратите внимание – выездной ремонт бытовой техники в челябинске
I love what you guys are up too. This kind of clever
work and coverage! Keep up the terrific works guys
I’ve you guys to blogroll.
Уборка квартир после пожара в Москве http://uborka-ot-pozhara.ru/
mexican pharmacies: concerta pharmacy coupons – bm pharmacy viagra
10 Essentials Concerning Lexus Replacement Key Fob You Didn’t Learn At
School Lexus Remote Key
The No. One Question That Everyone Working In Three Wheel Rollator With Seat Should Be Able
Answer three wheel rollators with seat
Pretty! This has been an incredibly wonderful article. Thank you for providing this information.
ретрит что это такое простыми словами https://ретриты.рф