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
not safe
https://rik-estate.ru/
https://image.google.com.et/url?q=https://generik-spb.ru
You’ll Never Guess This Misted Double Glazing Repairs Near Me’s Tricks
double Glazing repair
lesbian porn
9 Lessons Your Parents Taught You About Upvc Window Repair Near Me Window Repair Near Me
Medicines information for patients. What side effects can this medication cause?
can i get inderal without a prescription
Actual what you want to know about medication. Get here.
Manchester City and Erling Haaland https://manchester-city.erling-haaland-fr.com explosive synergy in action. How a club and a footballer light up stadiums with their dynamic play.
Legendary striker Cristiano Ronaldo https://an-nasr.cristiano-ronaldo-fr.com signed a contract with the Saudi club ” An-Nasr”, opening a new chapter in his illustrious career in the Middle East.
You ought to be a part of a contest for one of the finest websites on the net.
I am going to highly recommend this blog!
sex
Medicines information leaflet. Cautions.
order pregabalin sale
Actual what you want to know about drugs. Read now.
10 Things We All Hate About Collapsible Scooter Arlen Nizo
hacklink
Medicament information. Effects of Drug Abuse.
how to get mesalamine without rx
Actual what you want to know about medicament. Read information now.
Marcus Lilian Thuram-Julien https://internationale.marcus-thuram-fr.com French footballer, forward for the Internazionale club and French national team.
The Reason Behind Repair Upvc Windows Has Become The Obsession Of Everyone In 2023 upvc windows
repair (http://www.oceankorea.co.kr/)
Приветствую. Может кто знает, где найти разные статьи о недвижимости? Сейчас читаю https://toadmarket.ru
I like the valuable information you provide in your articles.
I’ll bookmark your blog and check again here regularly.
I’m quite sure I will learn many new stuff right here!
Best of luck for the next!
Pills information. Cautions.
where to get generic colchicine online
Everything information about medicines. Get here.
incest porn
Thank you for some other informative site. Where else may just
I am getting that kind of info written in such a perfect manner?
I have a project that I am just now running on, and I have been on the look out
for such info.
I know this if off topic but I’m looking into starting my own blog and was curious what all
is required to get setup? I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet smart so I’m not 100% positive.
Any recommendations or advice would be greatly appreciated.
Thank you
Официальный сайт онлайн-казино Vavada https://vavada-kz-game.kz это новый адрес лучших слотов и джекпотов. Ознакомьтесь с бонусами и играйте на реальные деньги из Казахстана.
What’s The Current Job Market For Veterans Disability Compensation Professionals?
Veterans disability
Starting a t-shirt store is often an rewarding venture for individuals wanting to explore the fashion market.
With a solid approach and commitment, a t-shirt shop could prosper and turn into a profitable enterprise.
Here are some essential steps to keep in mind when starting a
t-shirt shop.
### Business Plan
Creating a detailed plan is crucial for the success of
your t-shirt shop. This strategy should include the customer
base, promotional methods, budget, and objectives. Knowing your target market
is crucial to tailor your t-shirts and promotional activities to meet their needs.
### Creating the T-Shirts
Creating the design of your t-shirts is a important aspect in attracting buyers.
Hire skilled designers to develop eye-catching and fashionable graphics that resonate with
your target market. Consider utilizing diverse processes,
such as screen printing, DTG printing, and sublimation, depending
on your budget and the quality level of the apparel.
### Sourcing Materials
Choosing trustworthy manufacturers for your products is vital to make sure of consistent products.
Look for manufacturers that offer top-notch blank t-shirts in diverse colors.
Creating a good relationship with your vendors will help
maintain timely supply and affordable pricing.
### Creating an Online Store
In today’s internet era, having an online presence is essential for connecting with a more extensive market.
Develop an appealing and easy-to-navigate online store
to feature your products. Utilize high-quality photos and comprehensive
descriptions to give customers a clear sense of what they are
purchasing. Look into including elements like safe transactions systems,
customer reviews, and social sharing buttons to boost user engagement.
### Advertising and Marketing
Strategic promotion is crucial to driving visitors to your t-shirt
shop. Use multiple promotional methods,
such as social media, email marketing, influencer
marketing, and paid search ads. Platforms like Instagram,
Facebook, and TikTok enable you to connect with
a vast customer base and highlight your products.
Email campaigns is another way to stay in touch with your audience and update them
about new products, special offers, and upcoming collections.
Influencer marketing can additionally boost in accessing new customers.
### Customer Support
Providing outstanding after-sales service is crucial for building a loyal customer base.
Make sure that your customers have a positive interaction from
start to finish. Handle inquiries and problems efficiently and courteously.
Offering convenient returns and transparent conditions can help building trust with your customers.
### Reviewing Metrics
Regularly analyzing your business metrics can help identify areas
for enhancement and tweak your {strategies|approaches
I don’t know whether it’s just me or if perhaps everyone else
encountering problems with your website. It seems like some of the twxt in your content are running off the screen. Caan someone
else please comment and let me know if this is happening to them too?
This could be a issue wiith my browser because I’ve had this happen previously.
Cheers
10 Websites To Help You To Become A Proficient In Malpractice Legal Vimeo.Com
15 Gifts For The Replacement Windows Near Me Lover In Your
Life installed
Top Ideas For Improve Your Seo Google Page Rank
백링크 검사