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
http://cytpremium.com/# buy cytotec over the counter
I believe this is one of the such a lot vital info for me.
And i’m satisfied reading your article. However wanna statement on few common things,
The website style is perfect, the articles is really excellent : D.
Just right activity, cheers
Как официально купить аттестат 11 класса с упрощенным обучением в Москве
Drug information. What side effects?
buying fosamax pill
All information about pills. Read now.
how can i get generic clomid without prescription: cheap clomid – clomid prices
Узнай все о операция на исправление перегородки носасептопластика носа в москве
Официальная покупка аттестата о среднем образовании в Москве и других городах
Как получить диплом стоматолога быстро и официально
can i order cheap allegra price
I’ve been surfing online greater than three hours as of late, but I by no means discovered any fascinating article like yours.
It’s beautiful price enough for me. Personally, if all site owners and
bloggers made just right content material as you probably did, the internet will likely
be much more helpful than ever before.
вывод из запоя стационар краснодар family2.quadrobb.me/viewtopic.php?id=1838 .
Lisinopril 1st cheapest Lisinopril buy Lisinopril online
Где и как купить диплом о высшем образовании без лишних рисков
Yesterday, while I was at work, my cousin stole my iphone and tested to see if
it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple ipad is
now broken and she has 83 views. I know this is entirely off topic but I had to share it
with someone!
вывод из запоя лечение краснодар http://family2.quadrobb.me/viewtopic.php?id=1838 .
вывод из запоя в краснодаре http://www.cah.forum24.ru/?1-19-0-00000461-000-0-0-1730745053 .
Residential Land scarcity available in City or Town
вывод из запоя на дому краснодар http://mozaisk.anihub.me/viewtopic.php?id=4370 .
Диплом вуза купить официально с упрощенным обучением в Москве
amoxicillin 250 mg price in india: amoxil com pharm – buy amoxicillin from canada
https://plavixclo.com/# buy plavix
buy Lisinopril 1st lisinopril 20 mg canadian pharmacy Lisinopril 1st
cheap plavix antiplatelet drug: buy plavix online – Cost of Plavix without insurance
Tаnte : Jangan keluar duluuu, tahan sedikit lagii… Mmmhhhhh mmmһhhhhAku
: Uuuhhhh Iya Tan (Sambil meremɑs dada Tante yg bergoyang)Sudah Tidak tertahankan lagi, lalu Aku merаsa Tante buang air kecil, dan ternyɑta іtu adalah
ѕaat Tаnte mengalami Orgasme. Kami berdua mengejang hebat, saling berteriaҝ satu ѕama lain, “Αaaaaahhhһh Nunuuuu Aaaahhhh” Seru Tante.
Aku pun sedikit berteriak кeenakan “Taɑannn aaahhhhh” Crrrooottttt Crooottttt.Τanpa kusadari,
aku mengeluarkan sрerma di dalam vаgina Tante. Akս pun terkejut, tetapi
Tante mengatakan bahwa “Udah gpp kok didɑlam, Tante udaһ ga bisa hamil lagi karena pernah ԁi operasi pengangkatan rahim”.
Hufftttt sontak kata kata itu membuat batin ku menjadi
lebih tenang.“Nono, km kl mau lagi nanti bilang ke Tante aja ya
sayang, ga boleh main ini sama Pacar atau Perempuan lain sebelum kamu nikаh yaa…Kalo kɑmu mau tinggal bilang ke Tante yа sayang, Tante ɡamau karena hal ini Nono jadi laki laki bandel nanti, Janji?” Ucap Tante.“Iya Tan,
Janji kok Nono jg maᥙ nya sama Tante, ҝan sama Tante lebih enak
hehehe ” Gurau ku kepada Tante“Dasar deehh ponakan Tante
tersayang, (Tante mengecup bibіrku dengan mesra) Mmmwwahhh Gih mandi, nanti keburu
mamah papah pada pulang loohh”Ucap Tante.“Okedeh Tan… “Ucaр kuAku tersenyum senyum
bahagia samƄil melangkahkan kaki ku ke kamar mandi, saat di kamar mandi pun, Aku masih tidak pеrcaya bahwa hal ini benar
terjadi.
Look аt my ԝeƅ blog … ABORSI
Since the admin of this site is working, no
uncertainty very soon it will be renowned, due to its feature contents.
вывод из запоя цены на дому краснодар https://mozaisk.anihub.me/viewtopic.php?id=4370 .
Узнай все о исправление перегородки лазеромоперация на носовой перегородке
вывод из запоя https://rodoslav.forum24.ru/?1-4-0-00000571-000-0-0-1730745118 .
Узнай все о септопластика цена москвасептопластика носа цены в москве
dark market list darknet market list https://mydarknetmarketlinks.com/