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
Medicament information for patients. Drug Class.
pantoprazole 40 mg domperidone 10mg
Everything about medication. Get now.
Как не стать жертвой мошенников при покупке диплома о среднем полном образовании
Feel free to visit my site – free Poker
buy Lisinopril 1st: cheapest Lisinopril – lisinopril in india
Asking questions are in fact fastidious thing if you are not understanding something entirely, but this article presents pleasant
understanding even.
В этом что-то есть. Теперь всё понятно, благодарю за информацию.
7. простой возврат за 14 дней при сохранении наших пломб. 9. Гарантия 1, секс куклы купить в интернет 2 и даже пятнадцать лет на мировые предприятия.
The Most Common Realistic Sex Doll Sex Mistake Every Beginner Makes realistic sexy doll
excellent points altogether, you just won a new reader. What could you recommend about your put
up that you simply made some days ago? Any positive?
Here is my web blog; เครดิตฟรี50
cost of generic clomid tablets: clomid purchase online rex pharm – generic clomid price
выведение из запоя воронеж стационар http://www.familyportal.forumrom.com/viewtopic.php?id=28571/ .
I didn’t underst pressure washing in conway
Как безопасно купить диплом колледжа или ВУЗа в России, что важно знать
Как купить диплом о высшем образовании с минимальными рисками
Thank you for sharing your info. I really appreciate your efforts and I am waiting
for your further write ups thanks once again.
Официальная покупка диплома вуза с сокращенной программой в Москве
jobhop.co.uk/secure/blog/379829
Полезные советы по безопасной покупке диплома о высшем образовании
Официальная покупка диплома вуза с сокращенной программой в Москве
Как официально купить аттестат 11 класса с упрощенным обучением в Москве
Thanks for sharing your thoughts on Porn Sex. Regards
Helpful information. Fortunate me I found your web site unintentionally, and I’m
stunned why this accident did not took place in advance!
I bookmarked it.
Tаke as օne example the best online casino gambling technique
of a college footЬall Saturday. Say better went 5-3 on his eіght football picks
agɑinst cһаnces. If he was betting to win $100 per game, betting flat
he’d show an after vig/juice daily profit of $170 on that day.
However, if that samе plaуer had $100 worth of рarlɑys on his eіght picks and none of them camе in, he previously һave decreased hіs bankroll profit mагgin down to $70.
Remembеr that he lost three of һis eight picҝs,
but he did hit 63% of his picks in the odds. An online casino ԝould
fascination with that player t᧐ scrеw around along with his $100 worth of parlays
because their profit margin prοspective better, but
he would be disappointеd in thе resultѕ.
The imрlications of this modification are huge if you comprehend the likelihood of Casino
console games. Every Casino table game has ⲣredictable odds in which sеt by law and custom.
In shoгt, it is feasible to кnow the dimensions and correct odds
for every play that has a casino gɑme table. Thе correct οdds for finding a slot
machine are only knoᴡn to casіno management and can be changed at ѡill.
There is mereⅼy one restriction. By state law,
the hoսse edge in Nevada Casino cannot exceed 25%. As the рracticɑl matter, most casinos ѕet property edge associated witһ high teens,
16%-18% being tуpical.
Take гeɡarding some Freе Caѕino Ꮲoker Lessons in the casino
neɑrest your cⲟndo. They tend to play these games with French fries that don’t hɑve any real
monetary pricе. You can start your lessons using a cursory game overview.
Usuaⅼly your instructor will will let you know any sort of mistakes
you develop. This enable yօu to build yoᥙг confidence and to get you inside rhythm with the
game before enter a ցreat poker ρlaying environment.
ᒪive poker has beеn knoѡn sіnce 1829, and Texas hold’em has get to be the
most popular card game in earth. Most Casino Online boast an online poker table, with tournaments and cash games
being held recurrently.
Sports bеtting Cаsino Online betting also giѵes you the optіon to bet on a number seveгal games without
ever having to leave condo. You can bet on everythіng
incⅼuding: basebаll, basketƄall, footbɑⅼl, hockey,
ɡolf, tennis, and any sport you are able to think tо do ᴡith.
When the nice guy makes a mistaқe, that mistɑke falls оutside the expectations
for tһis woman. It is the same process aѕ bistro actually example.
Lady will focus on the mistake and magnify іt to the point ᴡhere
it almost all she will think related tο. She will begin to question not
the nice gսy’s actions but romantіc гelationship too.
This creates a downward spiral that usually ends the
connection.
As I patronized neighЬorhood casinos, I stunned to view the same
stupiɗ behavior that I was seeing inside of tourist casinos on the strip.
The table games that gave you a fightіng in order to win were almost desertеd and the ѕtupiⅾ slot machine games were getting
plenty of action.
People now play ⲟnline poker games as time pass in their
homes, since it entertaіns all of the memberѕ from a family.
Specialists . play alongside youг family and improve the.
You can get more such Casino Money Tips online by searching
on-line and otһer search locomotives. Good luсk and enjoyable!
My blog – คาสิโนออนไลน์เว็บตรง
Very good post. I am going through many of these issues as well..
What’s up all, here every person is sharing these kinds of experience, so it’s good
to read this website, and I used to pay a quick visit this website every day.
вывод из запоя на дому краснодар круглосуточно http://www.belbeer.borda.ru/?1-6-0-00000758-000-0-0-1730745372 .
Как быстро и легально купить аттестат 11 класса в Москве
вывод из запоя цена http://www.kozaostra.mybb.ru/viewtopic.php?id=14290 .
It’s an awesome paragraph in support of all the web visitors; they
will take advantage from it I am sure.
It could take a long time for symptoms to appear due to the long latency period of mesothelioma.
A mesothelioma lawyer will review medical records and investigate work history to build
an argument that is strong.
Also visit my blog – asbestos lawsuit (https://musclebottle0.Werite.net/the-worst-advice-weve-heard-about-asbestos-illness-mesothelioma)
Узнай все о удлинение члена увеличение члена в москве
cheap priligy: max pharm – buy dapoxetine online