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
https://slotsiteleri.bid/# en guvenilir slot siteleri
http://denemebonusuverensiteler.win/# deneme bonusu
homosexual porn
bonus veren casino slot siteleri: deneme bonusu veren siteler – deneme bonusu veren slot siteleri
I think the admin of this website is in fact working hard in favor of his website, because here every data is quality based
material.
Remarkable! Its truly awesome article, I have got much clear idea on the topic of from this article.
slot oyunlar? siteleri: slot siteleri 2024 – slot oyunlar? siteleri
Piece of writing writing is also a excitement, if you be acquainted with afterward you can write otherwise it is complex
to write.
Men, the analyze studies, ended up more likely to cite “noticed an possibility and took it” as a reason for committing adultery than girls ended up, whilst the women of all ages cited factors that experienced to do with the demise of the relationship. Here’s how Sperm Wars will work: According to a 2006 study published in Hormones and Behavior, gals are inclined to be unfaithful at the most fertile portion of their menstrual cycle, even if they’re not trying to get pregnant. And married adult men may often get a more substantial share of prospect from single gals, if a 2009 examine from the Journal of Experimental Social Psychology is any sign. I find myself consistently caught in the middle of the two of them and I detest viewing what this condition has done to my son, but with him out of work and me earning pretty tiny from social protection, there are not actually quite a few other decisions for us. Seeing and talking to other people who also have this condition can enable you experience significantly less disgrace or embarrassment about having the situation. Researchers theorize that the men in associations have been pre-screened and deemed acceptable as a mate, whilst the unattached men are higher unknowns. There are a couple of scientific tests which point out that girls are far more attuned to smaller difficulties within the partnership that spell doom, and that’s why they pursue affairs.
slot siteleri guvenilir: slot siteleri 2024 – slot siteleri bonus veren
Промокод на Фонбет https://kmural.ru/news_importer/inc/aktualnue_promokodu_bukmekerskoy_kontoru_fonbet.html
Использование промокода на Фонбет дает возможность получить разнообразные бонусы и привилегии при регистрации и игре. Промокоды могут предоставлять бесплатные ставки, увеличение суммы депозита, кэшбэк и другие виды вознаграждений. Чтобы активировать промокод, необходимо ввести его в специальное поле при регистрации или депозите. Например, промокод ‘GIFT200’ предлагает новым игрокам бесплатные ставки или другие бонусы. Правильное использование промокодов помогает пользователям увеличить свои шансы на выигрыш и делает процесс игры более захватывающим.
Разные страхи, напряжения, беспокойства, стыд, злость, обида и т.д. Это и есть якоря, которые отягощают нашу жизнь. Читать статью.
Психологические блоки – Лабиринты подсознания и их отражение в теле – Часть 2
https://slotsiteleri.bid/# deneme bonusu veren siteler
With havin so much content do you ever run into any problems of plagorism or copyright infringement?
My website has a lot of unique content I’ve either authored myself or outsourced but it appears a lot of it is popping it up all over the internet without my permission. Do you know any techniques to help
prevent content from being ripped off? I’d genuinely appreciate it.
The 10 Most Terrifying Things About Offset Bunk Beds offset bunk
beds (https://minecraftcommand.science/profile/punchbeer71)
Ev Taşıma | Ev taşırken profesyonel bir firma ile çalışmanın faydalarını bu yazınızda çok güzel özetlemişsiniz. Kozcuoğlu Ev Taşıma olarak, bu konuda müşterilerimize en güvenilir hizmeti sunuyoruz.
Terrific stuff Thanks a lot!
A seasoned mind best personal injury attorney los angeles lawyer
might be able to aid.
Как проходит расстановка. https://rasstanovkiural.ru
en iyi slot siteleri 2024: bonus veren slot siteleri – slot siteleri
http://slotsiteleri.bid/# slot bahis siteleri
Wonderful blog! I found it while searching on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Thank you
What is the copyright situation for film stills taken from DVDs and used in academic articles?
incest porn
xxx
https://slotsiteleri.bid/# yasal slot siteleri
Asking questions are in fact pleasant thing if you are not understanding something fully, except this article gives fastidious
understanding even.
10 Facts About Nissan Qashqai Replacement Key That Make
You Feel Instantly Good Mood Replacement Nissan keys
שיש כאן יודעות כיצד להקפיד לשמור על הדיסקרטיות והפרטיות שלך. ואם מדברים על חופש ובילויים, אתה חייב לראות את הבחורות. הנערות לגבי הבילוי עם נערות ליווי, אך המציאות שונה לגמרי. נערות ליווי מציעות מפגשים אינטימיים ברמה גבוהה. לעתים ישנם אנשים המסתכלים זונות רוסיות
watch porn video