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
Medicines information. Cautions.
can i get cozaar tablets
Best trends of pills. Get now.
Fantastic site you have herе bսt Ι ᴡas curious
aƅout if you kneᴡ of anyy community forums tһat cover thе ѕake topics talked ɑbout heгe?
I’d reaⅼly likе to be a рart of community
ԝherе І can get opinions from other experienced people tһɑt share thе sаme interest.
If уou һave any recommendations, ρlease let me know.
Apprecіate it!
Ηere iѕ mʏ blog akartoto
In Buffalo, New York, proper insulation is
crucial due to the city’s varied climate and the need for energy efficiency.
Insulation Depot USA provides top-notch insulation services, including attic insulation, wall
insulation, and spray foam insulation, ensuring homes and businesses in neighborhoods like Allentown and Elmwood Village are well-insulated and
comfortable year-round. The importance of reliable insulation cannot be overstated in Buffalo, where temperatures
can fluctuate significantly, making energy-efficient insulation critical for reducing energy
costs and maintaining a comfortable indoor environment.
Insulation Depot USA is located in Buffalo, a city founded in 1801.
Buffalo is a historic city with a population of 276,486 as of 2022 and 118,071 households.
The city is conveniently connected by Interstate 190, a major highway that
facilitates easy travel to and from the area.
An interesting fact about Buffalo is its rich history in the development
of the electric power industry, famously associated with Nikola Tesla
and the harnessing of power from Niagara Falls. Today, Buffalo
offers a blend of residential, commercial, and recreational opportunities,
making it an attractive place to live and work.
The cost of insulation repairs and installations in Buffalo can vary depending on the type of service required.
Basic services like attic or wall insulation might range from $1,000 to $3,
000, while more extensive work such as spray foam insulation or insulation removal can cost between $2,000 and $5,000.
Buffalo experiences a wide range of temperatures,
with summer highs reaching around 80°F and winter lows dropping to approximately 20°F.
These temperature variations necessitate reliable and efficient insulation to ensure
homes remain comfortable and energy-efficient throughout the year.
Buffalo boasts numerous points of interest that cater to a variety of tastes and preferences.
Niagara Falls is one of the most famous natural wonders in the world, attracting millions of visitors
each year. The Buffalo and Erie County Botanical Gardens offers a stunning display
of plant life in beautiful conservatories. The Buffalo
Zoo, one of the oldest in the country, provides a fun and educational experience
for families. The Albright-Knox Art Gallery showcases an impressive collection of modern and contemporary art.
Lastly, Canalside is a vibrant waterfront district with a variety of activities, including boating, concerts, and festivals.
Each of these attractions offers unique experiences that highlight Buffalo’s cultural and natural heritage.
Choosing Insulation Depot USA for insulation services in Buffalo is a wise decision for residents and businesses seeking
reliable and efficient solutions. The company offers a comprehensive range of services,
including insulation installation, soundproofing, and thermal
insulation. Insulation Depot USA’s commitment
to quality workmanship and exceptional customer
service ensures that all insulation needs are met promptly and professionally.
For those living in Buffalo, Insulation Depot USA is the trusted
partner for maintaining an energy-efficient and comfortable
living environment, providing peace of mind and comfort throughout the
year.
In Buffalo, New York, maintaining proper insulation is crucial due to
the city’s changing seasons and the need for
energy efficiency. Insulation Depot USA offers essential insulation services
such as attic insulation, wall insulation, and blown-in insulation, ensuring homes and businesses in neighborhoods like North Buffalo and South Buffalo stay warm in the winter and cool in the summer.
The significance of having a reliable insulation contractor in Buffalo cannot
be overstated, as proper insulation is vital for reducing energy costs and maintaining
a comfortable indoor environment throughout the year.
Insulation Depot USA operates in Buffalo, a city founded
in 1801. Buffalo is a historic city with a population of 276,486 as of 2022 and 118,071 households.
The city is well-connected by Interstate 190, a major highway that facilitates easy
travel across the region. An interesting fact about Buffalo is its role in the early development of the electric
power industry, famously associated with Nikola Tesla and the harnessing of power from Niagara Falls.
Today, Buffalo is known for its vibrant community and diverse recreational opportunities,
making it a great place to live and work.
The cost of insulation repairs and installations in Buffalo can vary widely depending on the
type of service required. Basic services like attic or wall insulation might range from $1,000
to $3,000, while more extensive work such as spray foam insulation or insulation removal can cost between $2,000 and $5,000.
Buffalo experiences a range of temperatures, with summer highs reaching around 80°F
and winter lows dropping to approximately 20°F. These temperature
variations necessitate reliable and efficient insulation to ensure homes remain comfortable
and energy-efficient throughout the year.
Buffalo offers numerous points of interest that cater to a variety
of tastes and preferences. The Buffalo and Erie County Botanical Gardens provide a stunning display of plant life in beautiful conservatories.
The Buffalo Zoo, one of the oldest in the country, offers a fun and educational experience for families.
The Albright-Knox Art Gallery showcases an impressive collection of modern and contemporary art.
Canalside is a vibrant waterfront district with a variety of activities, including boating, concerts, and festivals.
The Buffalo Museum of Science offers engaging exhibits and educational
programs for all ages. Each of these attractions offers unique experiences that highlight Buffalo’s
cultural and natural heritage.
Choosing Insulation Depot USA for insulation services in Buffalo is a wise decision for residents and businesses seeking reliable and efficient solutions.
The company offers a comprehensive range of services, including insulation installation, soundproofing, and thermal insulation. Insulation Depot USA’s
commitment to quality workmanship and exceptional customer service ensures that all insulation needs are met promptly
and professionally. For those living in Buffalo, Insulation Depot
USA is the trusted partner for maintaining an energy-efficient and comfortable living environment, providing
peace of mind and comfort throughout the year.
In Buffalo, New York, proper insulation is essential due to the city’s varied climate and the need for energy efficiency.
Insulation Depot USA provides top-notch insulation services, including attic insulation,
wall insulation, and spray foam insulation, ensuring homes and businesses in neighborhoods like West Side
and Downtown Buffalo are well-insulated and comfortable year-round.
The importance of reliable insulation cannot be overstated in Buffalo,
where temperatures can fluctuate significantly, making energy-efficient insulation critical for reducing energy costs and maintaining a comfortable indoor environment.
Insulation Depot USA is located in Buffalo, a city
founded in 1801. Buffalo is a historic city with a population of 276,486 as of 2022 and 118,071 households.
The city is conveniently connected by Interstate 190, a major highway that facilitates easy travel to and
from the area. An interesting fact about Buffalo is its rich history in the development of the electric power industry, famously
associated with Nikola Tesla and the harnessing of power from Niagara Falls.
Today, Buffalo offers a blend of residential, commercial, and
recreational opportunities, making it an attractive place to live and work.
The cost of insulation repairs and installations in Buffalo can vary depending on the
type of service required. Basic services like attic or wall insulation might range from $1,000 to $3,
000, while more extensive work such as spray foam insulation or insulation removal can cost
between $2,000 and $5,000. Buffalo experiences a wide range of temperatures, with summer highs reaching around 80°F and winter lows dropping to approximately 20°F.
These temperature variations necessitate reliable and efficient insulation to ensure homes remain comfortable and energy-efficient throughout the year.
Buffalo boasts numerous points of interest that cater to a variety of tastes and preferences.
The Buffalo and Erie County Botanical Gardens provide a stunning display of plant life in beautiful conservatories.
The Buffalo Zoo, one of the oldest in the country, offers a fun and educational experience for families.
The Albright-Knox Art Gallery showcases an impressive collection of modern and contemporary art.
Canalside is a vibrant waterfront district with a variety of activities,
including boating, concerts, and festivals.
The Buffalo Museum of Science offers engaging exhibits and educational programs for all ages.
Each of these attractions offers unique experiences that highlight Buffalo’s cultural and natural heritage.
Choosing Insulation Depot USA for insulation services in Buffalo is a wise decision for residents and businesses seeking reliable and efficient solutions.
The company offers a comprehensive range of services, including insulation installation, soundproofing, and thermal insulation. Insulation Depot USA’s commitment to
quality workmanship and exceptional customer service ensures
that all insulation needs are met promptly and professionally.
For those living in Buffalo, Insulation Depot USA is the trusted
partner for maintaining an energy-efficient and comfortable living environment, providing peace of mind and comfort throughout the year.
In Buffalo, New York, maintaining proper insulation is crucial due to the city’s changing seasons and the need for energy efficiency.
Insulation Depot USA offers essential insulation services such as attic insulation, wall insulation,
and blown-in insulation, ensuring homes and businesses in neighborhoods like
East Side and Black Rock stay warm in the winter
and cool in the summer. The significance of having
a reliable insulation contractor in Buffalo cannot be overstated, as proper insulation is vital for
reducing energy costs and maintaining a comfortable indoor environment throughout
the year.
Insulation Depot USA operates in Buffalo, a city founded in 1801.
Buffalo is a historic city with a population of 276,486
as of 2022 and 118,071 households. The city is well-connected by Interstate 190, a major highway that facilitates
easy travel across the region. An interesting fact about Buffalo is its
role in the early development of the electric power industry, famously associated
with Nikola Tesla and the harnessing of power from Niagara
Falls. Today, Buffalo is known for its vibrant community and diverse recreational opportunities, making it
a great place to live and work.
Romelu Menama Lukaku Bolingoli https://romelulukaku.prostoprosport-br.com Futebolista belga, atacante do clube ingles Chelsea e da selecao belga . Por emprestimo, ele joga pelo clube italiano Roma.
15 Unexpected Facts About Replacement Sash Windows That You’ve Never Heard Of glass
replacement for window (Maryellen)
Drugs information for patients. What side effects can this medication cause?
where buy generic aricept online
Best information about medicament. Get here.
Всем привет! Может кто знает, где почитать полезные блоги о недвижимости? Сейчас читаю https://1eve1.ru
10 Easy Steps To Start The Business Of Your Dream Truck Accident Claims Business Truck Accident Lawsuit
Where Do You Think Upvc Doors Birmingham One Year From Today?
Emergency boarding Birmingham
Double Glazing Repairs Near Me Tools To Streamline Your Daily Lifethe One
Double Glazing Repairs Near Me Trick That Should Be Used By Everyone Learn double glazing repairs near me
Five Killer Quora Answers To Car Accident Law Car Accident
Drugs information for patients. Long-Term Effects.
cost ramipril without prescription
Everything trends of medicament. Get information now.
Приветствую. Подскажите, где почитать разные статьи о недвижимости? Сейчас читаю https://1eve1.ru
Buying Online From Uk To Ireland Tools To Streamline Your Daily
Life Buying Online From Uk To Ireland Trick
That Every Person Must Be Able To Buying Online From Uk To Ireland
See What Online Clothing Sites Uk Tricks The Celebs Are Utilizing online clothing sites uk (http://moden126.mireene.com/bbs/Board.php?bo_table=uselist3&wr_id=261663)
cefixime potassium clavulanate side effects
Are GSA SER The Same As Everyone Says? gsa ser reviews; http://arrigonline.ch/peaktram/peaktram-spec-fr.php?num=3&return=http://chandler-galbraith.blogbright.net/10-facts-about-gsa-ser-software-that-will-instantly-put-you-in-a-good-mood/,
The 12 Worst Types Asbestos And Mesothelioma Users You Follow
On Twitter https://www.cassylawn.top/9xvo0wk-soid7oe-pc4oq-2my-we2-4617/
Medication information leaflet. Generic Name.
can you buy cheap zithromax without prescription
Best what you want to know about meds. Read information now.
Mobile vaporizers use batteries as a source of power.
Also visit my web blog :: is vape juice vegan
20 Fun Facts About Collapsible Scooter https://www.arlennizo.top/46y-rkx75g-g3m282-4u83lf-41dg65-2314/
The 10 Most Scariest Things About List Of Online Shopping Sites Uk online Shopping
10 Quick Tips For Counterstrike Ps5 cs2 case opening (soho1022.ooi.kr)
jasminer
See What Uk Online Shopping Sites For Mobile Tricks The Celebs Are Making Use Of uk online Shopping sites for mobile
Drug information sheet. What side effects can this medication cause?
can i buy dramamine for sale
All information about medicament. Get information here.
20 Inspirational Quotes About Private ADHD Diagnosis UK Cost
private adhd assessment gloucestershire
What is New U Life SOMADERM Transdermal Gel.
My web page :: ai headshot generator free website
Ridiculous quest there. What happened after? Take care!
Pills information. Short-Term Effects.
can i purchase generic paxil no prescription
Actual information about medicament. Read information here.