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
What’s up to all, it’s actualⅼy а good for me tо pay a quick visit tһis website, it contains
іmportant Ӏnformation.
Check oսt mʏ blog; casino (Byron)
Hello! I’ve been following your site for a while now and finally got the bravery to go ahead and give
you a shout out from New Caney Tx! Just wanted to mention keep up the fantastic work!
https://lisinopril.top/# lisinopril pills 10 mg
http://stromectol.fun/# stromectol 12mg
Could Affordable & Amazing Filipino Ladyboy Manila & Cebu Be The Key
For 2023’s Challenges?
Here is my web site :: ladyboy dating site
otc lisinopril: zestril brand – how to order lisinopril online
Incredible story there. What occurred after?
Take care!
Hello! This is my 1st comment here so I just wanted
to give a quick shout out and tell you I genuinely
enjoy reading through your blog posts. Can you suggest
any other blogs/websites/forums that cover the same subjects?
Thanks for your time!
Auto Affordable insurance policy is a significant factor for any auto manager.
Make certain you possess the correct insurance coverage.
Профессиональная выездная химчистка мягкой мебели и ковров в Краснодаре и крае химчистка краснодар
My coder is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the expenses. But he’s tryiong none the less.
I’ve been using Movable-type on several websites for
about a year and am worried about switching to another platform.
I have heard excellent things about blogengine.net.
Is there a way I can import all my wordpress content into it?
Any help would be greatly appreciated!
Howdy! This is my first visit to your blog!
We are a collection of volunteers and starting a new initiative in a community in the same niche.
Your blog provided us valuable information to work
on. You have done a wonderful job!
lisinopril 5 mg tablet price: zestril 5 mg tablet – buy cheap lisinopril
lasix pills: generic lasix – lasix for sale
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 bit, but other than that, this is wonderful blog. An excellent read. I will certainly be back.
Ipaedia is a distinguished Dawah, research, and educational encyclopedia curated by esteemed Islamic scholars. Rooted in profound knowledge, this website serves as a beacon for seekers of wisdom and understanding in the realm of Islam. Meticulously written and edited, Ipaedia encompasses a wealth of information, providing valuable insights into Islamic teachings, promoting research, and fostering educational growth. With a commitment to authenticity and accuracy, the platform stands as a reliable source for individuals eager to delve into the rich tapestry of Islamic wisdom. Ipaedia embodies a digital sanctuary where the light of knowledge illuminates the path of enlightenment, facilitating a deeper connection with the tenets of Islam.
https://furosemide.guru/# furosemida 40 mg
If skme one needs to be updated ѡith latest technologies after that he must be visit this web
pagte and be up tto date all the time.
my website – Video tron
How Double Glazed Units Near Me Was The Most Talked About Trend In 2023 repaired
cost of lisinopril in mexico: lisinopril 420 1g – lisinopril prescription
10-Pinterest Accounts You Should Follow Link Daftar Gotogel link daftar Gotogel
https://lisinopril.top/# order lisinopril from mexico
What Is Saab 93 Key Replacement And Why Is Everyone Dissing It?
Saab Key Fob Programming
Your Complete Guide to Rain Gutter Installation, Rain Gutter Protector Installation, and Rain Gutter Cleaning Assistance
If you’re a homeowner, you understand the value of maintaining a efficient rain gutter setup. Gutters serve a crucial function in safeguarding your house from rainwater harm by channeling rainwater away from the top and foundation. However, making sure your gutters are in top condition demands more than just occasional cleaning. From gutter installation to rain gutter protector installation and rain gutter cleaning assistance, this comprehensive manual covers everything you need to understand to keep your rain gutters in top shape.
Gutter Setting up
Why Gutters Are Important
Before we dive into rain gutter setting up, let’s comprehend why gutters are crucial for your home. Rain gutters help stop rainwater harm by directing rainwater away from your home’s foundation, walls, and landscaping. Without proper water drainage, rainwater runoff can cause wear and tear, basement flooding, mold growth, and constructional damage.
Signs You Require New Gutters
Cracks or Rust: Visible cracks or rust spots suggest that your gutters are deteriorating and may need to be replaced.
Sagging or Pulling Away: Gutters that sag or pull away from the house are not efficiently directing rainwater away and ought to be replaced.
Water Damage: Water stains on the exterior of your home or basement flooding might suggest that your gutters are failing to do their job.
Frequent Clogs: If your gutters are continuously clogged with debris, it might be time to invest in an updated gutter system that is easier to upkeep.
Gutter Materials
When it comes to gutter materials, one have several options to choose from:
Aluminum: Lightweight, rust-resistant, and accessible in a variety of colors.
Vinyl: Affordable, easy to set up, and low maintenance.
Steel: Durable and appropriate for regions with harsh weather conditions.
Copper: Elegant, long-lasting, and adds decorative flair to your home.
DIY vs. Professional Setting up
While some homeowners may try to install gutters themselves, it’s often best to leave this job to the professionals. Professional rain gutter installers have the experience, tools, and expertise to ensure that your rain gutters are installed correctly and operate optimally. Plus, hiring a professional can save you time and hassle in the long run.
Rain Gutter Guard Installation
The Importance of Gutter Guards
Rain Gutter guards are an essential addition to any rain gutter system. These protective covers prevent leaves, twigs, and debris from clogging your rain gutters, minimizing the need for regular cleaning and reducing the risk of water damage to your home.
Types of Rain Gutter Guards
Mesh Screens: Fine mesh screens allow water to flow through while blocking debris.
Reverse Curve: These rain gutter guards feature a curved surface that directs water into the rain gutter while preventing leaves and debris from entering.
Brush Inserts: Brush-style inserts fit inside the rain gutter and stop leaves from accumulating while allowing water to flow freely.
Foam Inserts: Foam gutter guards block debris while allowing water to filter through.
Professional Setting up vs. DIY
While some homeowners might try to set up rain gutter guards themselves, professional installation is often recommended. Professional installers can ensure that gutter guards are properly fitted and securely attached, reducing the risk of debris buildup and water damage.
Gutter Cleansing Assistance
The Importance of Rain Gutter Cleaning
Regular gutter cleaning is essential for upkeeping a functional gutter system. Over time, leaves, twigs, and debris can accumulate in your rain gutters, resulting to clogs and water overflow. Professional rain gutter cleaning assistance can help prevent these issues and extend the life of your rain gutters.
Signs You Require Rain Gutter Cleaning
Visible Debris: If you observe leaves, twigs, or other debris in your rain gutters, it’s time for an cleansing.
Water Overflow: Overflowing gutters during rainstorms suggest that they are clogged and need to be cleaned.
Sagging Rain Gutters: Rain gutters that sag or pull away from the home may be weighed down by debris and require cleaning.
<a href=https://www.tiktok.com/@jgutterguardsgutter guard company
Frequency of Gutter Cleaning
The frequency of gutter cleaning depends on several factors, including the surrounding vegetation, climate, and rain gutter guard installation. In general, it’s recommended to clean your rain gutters at least twice a year, ideally in the spring and fall, to remove seasonal debris buildup.
Conclusion
Maintaining a functional rain gutter system is essential for safeguarding your house from water damage and preserving its structural integrity. Whether you require gutter installation, gutter guard installation, or rain gutter cleaning services, investing in professional assistance can save you time, money, and hassle in the long run. By prioritizing maintenance, you can ensure that your house remains safe, dry, and secured for years to come.
Wow that was strange. I just wrote an very long comment but after I clicked submit
my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say excellent blog!
https://lisinopril.top/# lisinopril 40 mg brand name in india
I loved as much as you’ll receive carried out right here.
The sketch is tasteful, your authored subject matter
stylish. nonetheless, you command get got an nervousness over that you wish be
delivering the following. unwell unquestionably come further formerly again since
exactly the same nearly a lot often inside case you shield this hike.
lisinopril 5 mg daily: buy lisinopril 20 mg without prescription – lisinopril pill 10mg
lisinopril 80 mg tablet: lisinopril 420 – lisinopril comparison
Do you want to give your roof a second chance? Shingle Magic Roof Sealer is your solution. The exceptional product provides
an unparalleled degree of care for your asphalt shingles, guaranteeing they remain durable.
Utilizing Shingle Magic Roof Sealer, you’re not
just applying any ordinary product. You’re selecting a top-quality roof rejuvenation solution designed to significantly prolong the life of your roof for decades.
It’s a smart choice for property owners seeking to safeguard their investment.
The reason to opt for Shingle Magic Roof Sealer?
For starters, its proprietary formula seeps into the asphalt shingles, restoring their original
strength and aesthetic. Additionally, it’s incredibly easy to apply, demanding no work for
top results.
Besides Shingle Magic Roof Sealer extend the life of your roof, it also offers
exceptional resistance to environmental damage.
Whether it’s harsh sunlight, heavy rain, or winter conditions, it will be shielded.
Moreover, selecting Shingle Magic Roof Sealer signifies you’re selecting
an eco-friendly option. The safe formula means little
environmental impact, which makes it a thoughtful choice for your
home.
Finally, Shingle Magic Roof Sealer excels as the ultimate roof rejuvenation solution. Not only does it increase
the life of your roof while delivering superior protection and a eco-friendly option makes Shingle Magic as the
wise choice for those seeking to care for their property’s future.
Furthermore, an important feature of Shingle Magic Roof Sealer
is its affordability. Instead of pouring a significant amount on frequent repairs or a full roof replacement, using Shingle
Magic helps save you costs in the long run. It’s a financially savvy choice that offers premium results.
Furthermore, the user-friendly nature of Shingle Magic Roof
Sealer is a major plus. You don’t need professional expertise to apply it.
For those who like to handle things themselves or prefer for a professional to do the job, Shingle
Magic provides a straightforward process with remarkable results.
Its longevity is yet another compelling reason to choose it.
Once applied, it creates a shield that preserves the integrity of your shingles for
a long time. This means fewer concerns about damage from the elements and greater peace of mind about the state of your roof.
In terms of appearance, Shingle Magic Roof Sealer is also superior.
It not only protects your roof but also improves its appearance.
Shingles will seem refreshed, thus adding to the curb appeal and market value to your property.
Satisfaction with Shingle Magic Roof Sealer is additional proof to its efficacy.
Many customers have seen remarkable improvements in their roof’s health after using the
product. Feedback highlight its simplicity, longevity, and superior protective
qualities.
In conclusion, selecting Shingle Magic Roof Sealer is choosing a reliable solution for roof rejuvenation.
With its blend of longevity, visual appeal, affordability, and user-friendliness makes it the perfect choice for
those wishing to enhance the life and appearance of their roof.
Act now to transform your roof with Shingle Magic Roof Sealer.