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
PG SLOT เว็บตรง ไม่มีขั้นต่ำ
สล็อตเว็บตรง ไม่ผ่านเอเย่นต์
SLOT PG เว็บใหม่ 2021
pg slot เว็บตรง
Fastidious replies in return of this issue with
real arguments and telling all concerning that.
Hello there! Would you mind if I share your blog
with my zynga group? There’s a lot of folks that I think would really enjoy your content.
Please let me know. Thank you
Its like you read my mind! You appear to know a lot about this,
like you wrote the book in it or something.
I think that you could do with a few pics to drive the message home a little bit,
but instead of that, this is magnificent blog. A fantastic
read. I will definitely be back.
Great work! That is the type of information that are meant to be shared around the
net. Shame on the search engines for not positioning this put up upper!
Come on over and consult with my website .
Thanks =)
Hello there! This is kind of off topic but I need some guidance from an established blog.
Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick.
I’m thinking about making my own but I’m not sure where to begin. Do you have any points or suggestions?
Cheers
Have you ever thought about creating an ebook or guest authoring on other blogs?
I have a blog based on the same information you discuss and would love to have
you share some stories/information. I know my audience would value your
work. If you are even remotely interested, feel free to send me
an email.
Sie haben ihren eigenen Pool. Unter Corona ist das verboten. Die Baustelle liegt auf Eis.
Den kompletten Maßnahmenkatalog des Tourismusministeriums scheint noch
keiner gesehen ohne Mann. Yesim Yalcin ist Ärztin in Antalya
und macht manche Tage mit ihrem Bruder und seiner
Frau hier Urlaub. Das Hotel bleibe diese Saison gut beraten sein zu.
Normalerweise wird dann war’s das des Fastenmonats mit Familie und Freunden gefeiert.
Nicht nur Sevki Erdogan hofft, dass viele Einschränkungen Anfang Juni fallen.
Bis Mitte Juni warnt die Bundesregierung allerdings alle
Deutschen, ins Ausland zu reisen. Um deutsche Urlauber trotz Corona wieder
in die Türkei zu locken, holt die Regierung in Ankara den TÜV ins Boot.
In der Gegenwart sind seine Hotelzimmer alle leer, nur mehrere der luxuriösen Villen sind belegt.
Ein Hotelzimmer hätte sie allerdings nicht genommen.
Die dürfen gegenwärtig allerdings nicht benutzt werden. Ferienhäuser werden diese Saison wohl insgesamt mehr gefragt sein.
Schwimmen und Spazieren am Meer ist verboten. Die Türkei will, dass sie das
so weit wie den Sommerferien aufhebt. Der Küstenort Kas in der Türkei im Oktober 2019 – damals war die Welt noch frei
von Corona. Bad untrennbar der Zimmer begutachtet. Im kleinen Boutique-Hotel fragen vor
allem Merih Ciraks Stammgäste, wann sie diese Saison aufmacht.
Der Hotelchef kann das nur Bahnhof verstehen “Zu sehen sein einige Entscheidungen, die hoffnungsloses Unterfangen”, sagt
er. Ihr Vater bleibt dagegen dabei: Urlaub mit Corona mache keinen Spaß
und sei gefährlich. Sicher ist das aber nicht.
Good post however I was wondering if you could write a litte more on this
topic? I’d be very thankful if you could elaborate a little bit further.
Kudos!
Thank you for every other magnificent post. The place else may anyone get that
kind of information in such a perfect method of writing?
I’ve a presentation subsequent week, and I am at the look for such information.
After exploring a number of the articles on your website,
I honestly appreciate your way of blogging. I saved as a favorite it to my bookmark website
list and will be checking back soon. Please check
out my web site too and let me know your opinion.
Very shortly this web page will be famous amid
all blogging users, due to it’s pleasant content
Wonderful beat ! I would like to apprentice whilst you amend your site,
how could i subscribe for a weblog web site? The account helped me a appropriate
deal. I had been tiny bit familiar of this your broadcast offered bright transparent concept
Hey I know this is off topic but I was wondering if you knew of any
widgets I could add to my blog that automatically tweet my newest twitter
updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you
would have some experience with something like this. Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to
your new updates.
Hi, I would like to subscribe for this weblog to obtain most recent
updates, so where can i do it please help.
This information is invaluable. How can I find out more?
Howdy! Do you know if they make any plugins to protect against
hackers? I’m kinda paranoid about losing everything I’ve
worked hard on. Any recommendations?
After I initially left a comment I appear to have clicked on the -Notify me when new comments are added- checkbox and
from now on every time a comment is added I get 4 emails with the exact same comment.
There has to be an easy method you are able to
remove me from that service? Thanks!
Thanks for sharing your thoughts about situs slot online indonesia.
Regards
Nur aus dringenden betrieblichen oder in der Person des Arbeitnehmers liegenden Gründen ist eine Übertragung des Urlaubs auf das nächste
Kalenderjahr statthaft; in diesem Moment muss der Urlaub in den ersten drei Monaten des folgenden Kalenderjahrs gewährt und
genommen werden. Kuren und Schonzeiten dürfen nicht auf den Urlaub angerechnet werden, soweit
ein Anspruch auf Entgeltfortzahlung im Krankheitsfall (Entgeltfortzahlung)
besteht. Während des Bestehens des Arbeitsverhältnisses gilt ein Abgeltungsverbot.
6. Vergütung: Urlaubsentgelt, Urlaubsgeld. Erkrankt ein Arbeitnehmer während des Urlaubs, so
werden die durch ärztliches Zeugnis nachgewiesenen Tage der Arbeitsunfähigkeit auf den Jahresurlaub nicht angerechnet.
Kann der Urlaub wegen Beendigung des Arbeitsverhältnisses
ganz oder teilweise nicht mehr gewährt werden,
so ist er abzugelten. Mit Ablauf des Übertragungszeitraums wird der Arbeitgeber von der Verpflichtung zur Urlaubsgewährung frei, soweit er
nicht die Unmöglichkeit der Urlaubsgewährung zu vertreten hat.
Hat der Arbeitnehmer im laufenden Urlaubsjahr nur
einen Teilanspruch wegen nicht erfüllter Wartezeit, so ist dieser Urlaub auf verlangen des Arbeitnehmers auf Gesamteindruck nächste Urlaubsjahr zu übertragen und hiermit
Urlaub des folgenden Jahres zu gewähren.
Hello mates, how is everything, and what you want to say on the topic of this
paragraph, in my view its in fact amazing in favor of me.
What’s up, just wanted to tell you, I liked this post.
It was helpful. Keep on posting!
Mondphase, Mondtag, günstige Tage – das alles findest du in diesem Beitrag und in den Tabellen unten. Einen schönen Tag
noch! Der Mondkalender zeigt Ihnen, was an einem bestimmten Tag gut beraten sein zu tun ist.
Lass dir vom Mond helfen. Mondkalender haare schneiden 2022 – finden Sie heraus, welcher Mondtag heute ist!
Wie verwende ich den Mondkalender? Was ist ein Mondkalender haare schneiden 2022?
Was ist ein Mondkalender haare schneiden 2022?
Die Emotionen, die der Mond symbolisiert, können sich an glückverheißenden und nicht glückverheißenden Tagen sehr stark ändern. Der Mond
hat wie die Sonne einen sehr starken Einfluss aufs menschliche Verhalten. Es hängt alles
von der Mondphase, dem Sternzeichen und dem Mondtag ab.
Der Mond beeinflusst auch Ebbe und Flut. Es kann voll, abnehmend
und wachsend sein. Der Mondkalender zeigt nicht nur den heutigen Mondtag, die Mondphase, das Tierkreiszeichen, im sich der Mond befindet, sondern gibt auch spezielle Empfehlungen zu verschiedenen Lebensthemen.
I think this is one of the most important information for me.
And i am glad reading your article. But wanna remark on few general
things, The web site style is wonderful, the articles is really excellent : D.
Good job, cheers
When some one searches for his required thing, thus he/she wishes to be available
that in detail, so that thing is maintained over here.
Just wish to say your article is as surprising. The clearness in your put up is simply
cool and that i could suppose you are a professional on this subject.
Fine together with your permission let me to grab your feed to stay updated
with imminent post. Thanks 1,000,000 and please continue the enjoyable work.
I visited multiple sites but the audio quality for audio
songs existing at this website is actually excellent.
Thanks , I’ve just been searching for information approximately this subject
for a long time and yours is the greatest I have found out till now.
But, what in regards to the conclusion? Are you positive concerning
the source?
Hi, There’s no doubt that your web site might be having web browser compatibility problems.
Whenever I take a look at your website in Safari, it looks fine however,
when opening in Internet Explorer, it’s got some overlapping issues.
I simply wanted to give you a quick heads up! Aside from that, wonderful blog!
Hey would you mind letting me know which webhost you’re utilizing?
I’ve loaded your blog in 3 completely different web browsers and I must say this
blog loads a lot quicker then most. Can you recommend a good hosting provider at a fair
price? Thank you, I appreciate it!