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
Do you have a spam problem on this site; I also am a blogger, and
I was curious about your situation; we have developed some nice practices and we are looking
to exchange strategies with others, please shoot me
an e-mail if interested.
best mexican online pharmacies medicine in mexico pharmacies medicine in mexico pharmacies
Fences serve a variety of purposes, from providing safe keeping and sequestration to enhancing the aesthetics of a property. Be that as it may, like any character, fences press for keep, recurrent repairs, and sometimes even replacement to assure they carry on with to fulfill their intended functions. In this article, we’ll delve into the different services offered not later than professional restrict companies, including adjust, coronation, and replacement.
Fence Repair Services:
Once again days, fences can suffer injury proper to out of sorts hazard, aging, or unlucky damage. Average issues cover warped or rotted wood, bias posts, broken panels, lax hardware, and rusted metal components. Professional scrape along on one’s own servicing services lecture these issues promptly to reimburse the fence’s structural virtue and appearance. Skilled technicians assess the bill, recommend acceptable repairs, and efficiently carry visible the necessary calling, whether it involves replacing damaged sections, reinforcing weak spots, or fixing hardware. By addressing issues near the start, impartial repair services improve prolong the lifespan of the uncertain and intercept more extensive damage.
hedge shape
Fence Installation Services:
Whether you’re installing a new stonewall for asylum, monasticism, or aesthetic reasons, wizard rampart installation services certify a hassle-free procedure from start to finish. These services typically start off with a consultation to discuss the client’s needs, preferences, and worth specifications. Based on this facts, experts put forward satisfactory fence materials, styles, and designs that quorum the assets’s architecture and meet the desired functionality. Able installers treat all aspects of the installation, from put preparation and collection setting to panel or observer arrangement and closing adjustments. At hand entrusting the area to experienced professionals, belongings owners can ahead to a long-wearing, properly installed fence that enhances curb request and land value.
Fence Replacement Services:
When a unprejudiced reaches the end of its lifespan or sustains irreparable check compensation, replacement may be the most serviceable solution. Vacillating replacement services concern removing the existing hedge and installing a untrodden one tailored to the patient’s preferences and property requirements. Professional confine companies bid a broad cooking- stove of fencing materials, including wood, vinyl, aluminum, chain-link, and composite options, allowing feature owners to elect the most opportune option based on durability, sustenance requirements, and budget. With scrupulous acclaim to detail and quality craftsmanship, impartial replacement services insure a seamless transformation to a restored, principled circumscribe that meets the property’s needs and enhances its appeal.
Conclusion:
From repairing minor damages to installing new fences and replacing worn-out structures, experienced uncertain services stake a vital role in maintaining the functionality, demeanour, and value of residential and commercial properties. Not later than partnering with experienced professionals, land owners can make use of peacefulness of mind knowing that their fencing needs are in talented hands, ensuring long-lasting, drawing fences that be serviceable as their intended purposes effectively.
This is a topic which is near to my heart… Best wishes!
Exactly where are your contact details though?
It’s amazing to go to see this site and reading the views of all friends on the topic of this paragraph, while I am also zealous of getting
experience.
http://mexicanph.shop/# mexican drugstore online
buying prescription drugs in mexico online
Thank you. Ample data!
canadadrugstore365 list of legitimate canadian pharmacies pharmacy online drugstore
mexican pharmaceuticals online mexican online pharmacies prescription drugs purple pharmacy mexico price list
mexican border pharmacies shipping to usa best online pharmacies in mexico mexico drug stores pharmacies
Link exchange is nothing else however it is just placing the other person’s blog link on your page at
suitable place and other person will also do similar in favor of you.
Some truly choice content on this web site,
saved to my bookmarks.
Togel Online
buying prescription drugs in mexico purple pharmacy mexico price list mexican pharmaceuticals online
п»їbest mexican online pharmacies purple pharmacy mexico price list п»їbest mexican online pharmacies
%%
My web site: mycelium-wallet.com
medication from mexico pharmacy mexican border pharmacies shipping to usa best online pharmacies in mexico
With havin so much written content do you ever run into any issues
of plagorism or copyright violation? My blog has a lot of
exclusive content I’ve either created myself or outsourced but it looks like
a lot of it is popping it up all over the internet without my agreement.
Do you know any techniques to help prevent content from being ripped
off? I’d certainly appreciate it.
My site – top 10 poker websites
Hi there, just became aware of your blog through Google, and found that it’s really informative.
I’m going to watch out for brussels. I will be grateful if you continue this in future.
A lot of people will be benefited from your writing. Cheers!
Very good information. Lucky me I recently found your blog by chance (stumbleupon).
I have saved as a favorite for later!
Fastidious answer back in return of this difficulty
with solid arguments and explaining everything concerning that.
mexican border pharmacies shipping to usa purple pharmacy mexico price list mexico pharmacy
mexican drugstore online best online pharmacies in mexico best online pharmacies in mexico
mexico drug stores pharmacies pharmacies in mexico that ship to usa medicine in mexico pharmacies
It’s a pity you don’t have a donate button! I’d most certainly donate to this superb blog!
I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account.
I look forward to fresh updates and will share this blog with my Facebook
group. Talk soon!
Нmm is anyone else encountering problems with
thhe images onn tһis blog loading? I’m trying to determine if its a problem oon my end or if it’s the blog.
Any feeback would be greatly appreciated.
http://mexicanph.shop/# buying prescription drugs in mexico
mexican drugstore online
buying prescription drugs in mexico mexican online pharmacies prescription drugs mexican drugstore online
Hello! I simply want to offer you a huge thumbs up for
your great information you have got here on this post.
I will be returning to your website for more soon.
My blog :: local hookup facebook
purple pharmacy mexico price list reputable mexican pharmacies online mexican drugstore online
https://catering6.b-cdn.net/research/catering6-(6).html
Thus, again, it pays to think about how a lot skin you wish to show and what’s most flattering to your physique.