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
ebuca.cc
Узнай все о варикоцеле варикоцеле у мужчин
amoxicillin no prescription amoxil can i buy amoxicillin online
Как безопасно купить диплом колледжа или ПТУ в России, что важно знать
Всем привет! Может кто знает, где найтиполезные статьи о недвижимости? Сейчас читаю – https://amkproekb.ru
It’s remarkable to visit this website and reading
the views of all mates regarding this article, while I am also zealous of getting know-how.
Тут можно преобрести сейф для оружия купить оружейный сейф в москве
priligy: dapoxetine price – priligy
Купить диплом о среднем полном образовании, в чем подвох и как избежать обмана?
etoiledeurope.com/kupit-diplom-2004.html
Узнай все о варикоцеле у мужчин варикоцеле яичка
Всем привет! Может кто знает, где найтиполезные блоги о недвижимости? Пока нашел – https://amkproekb.ru
order generic clomid: rex pharm – where to buy generic clomid without rx
Your Worst Nightmare About Truck Attorney Near Me Bring To Life
Truck accident attorney – lovewiki.faith,
tor markets links darknet site dark web link
Узнай все о варикоцеле 1 степени рецидив варикоцеле
Тут можно преобрести сейф под ружье купить оружейный сейф для пистолета
What You Can Do To Get More Out Of Your Beans
Coffee Machine Bean-to-Cup machine
max pharm: cheap priligy – priligy max pharm
Way cool! Some extremely valid points! I appreciate you penning this article and also the rest of the site is extremely good.
Приобретение диплома ПТУ с сокращенной программой обучения в Москве
umzugskartons-guenstig.info/diplom-o-visshem-obrazovanii-kupit-v-novokuznetske.html
Как купить аттестат 11 класса с официальным упрощенным обучением в Москве
Тут можно преобрести шкафы для оружия сейфы купить сейф оружейный
Ever looked for a quick and easy way to start generating money but
felt like there was practically nothing you may do?
That’s just not legitimate anymore. The web has provided us with extra methods to make money than we’ve ever experienced up to
now.
In excess of decades, the music has become an anthem to mock
capitalist obsession and profits disparities, a standard societal theme today.
It carries on for use in different media, such as movies,
television collection and commercials.
Time and energy to initially payment: Once you promote an item,
count on a wait around period of around five times to receive
resources within your checking account on most platforms.
Monetize your Twitch channel by promoting goods utilizing the Shopify Starter Approach—This
really is An easily affordable alternate to a full ecommerce Internet site plan.
It’s possible you’ll notice that other discounts goods meet your monetary demands a lot
better than a money sector account. Below are many of the alternatives you might want to look at.
Request about withdrawal selections and the surplus transaction fee of every institution prior to deciding
to open up an account.
Web builders are entrance-conclusion builders use programming languages which
include HTML, CSS, and Javascript to develop web pages for Internet sites.
In addition they must enhance Web page effectiveness.
Watch all investmentsStocksFundsBondsReal estate
and alternative investmentsCryptocurrencyEmployee equityBrokerage accounts529 university personal savings plansInvestment account reviewsCompare online brokerages
Thinking about customers are now observing several of
the best money marketplace fees they’ve witnessed in many years, this development is likely to carry on so long as banking companies are ready to contend for new deposits.
On the other hand, prices are more likely to commence trending downward in some unspecified time in the future
following calendar year.
If you like animals, it’s possible you’ll offer you pet
sitting down services in your house. Pet owners can take advantage of your services any time They are really
out of city or just have to have a split. You should choose whether or not you should care for puppies, cats or all kinds of
Animals.
Work amount: Medium to substantial, based on products and talent to develop a shopper base.
Very low energy to take care of.
Our professionals rated Sallie Mae Lender’s money industry account highly because savers can pair
this aggressive MMA With all the bank’s SmartyPig price savings account.
The SmartyPig Account includes equipment to
build and monitor progress towards particular money ambitions—like
an internet piggy financial institution.
Money industry accounts typically use tiered curiosity fee structures to award much better rates to
customers with bigger balances. Determine which stability tier you’d most likely tumble into ahead of opening an account.
Video is now an increasingly common variety of marketing
and advertising and marketing, and many firms
are starting their particular YouTube channels.
Anybody who appreciates how you can edit movies professionally can make money by providing this
service. Well-liked application to employ contain
https://www.craigatkinsonremovals.com/
FREE MONEY
PORN
MONEY
CASINO
FUCK
SEX
MOM FUCK SON
SON FUCK MOM
price for amoxicillin 875 mg Amoxicillin for sale order amoxicillin online no prescription
Great post but I was wanting to know if you could write
a litte more on this topic? I’d be very grateful if you could elaborate a
little bit more. Kudos!
What’s up it’s me, I am also visiting this site regularly,
this site is truly good and the users are truly sharing fastidious thoughts.
clomid medication clomid online where can i get cheap clomid for sale
This piece of writing is truly a pleasant one it helps new web
visitors, who are wishing for blogging.
Тут можно преобрести оружейные сейфы в москве сейфы для оружия купить
max pharm: priligy max pharm – Priligy tablets