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
The Little-Known Benefits Of Slot Demo Gratis Demo slots
The Most Advanced Guide To Online Shop Kelty Redwing Tactical
Pack (Vimeo.com)
20 Fun Infographics About Free Casino Slots fruit Slots [https://images.google.com.Na/]
Why No One Cares About Uk Online Phone Shopping Sites U19Bo Replacement Blades – vimeo.com,
A Brief History Of The Evolution Of Slot Wins top software Providers for slots
Overview on Imitation Upscale Accessories
Causes of an Popularity for Imitation Designer Handbags
Imitation Premium Luggage Have Surged With Demand DueTo Numerous Powerful Factors
Price Represent Frequently The Influencing Reason
Exceptional InspiredVersions Provide An Allure From Designer Brands Without The High Expense
Developments With Building Symbolize Which Those Versions Frequently Have Outstanding Likenesses To A Genuine
With Those Who Value Design Nonetheless Are Frugal
Replica Upscale Accessories Present An Appealing Replacement
Guidelines To Recognizing Validity
Inspecting Characteristics Including Icons Joints Plus Fittings
Will Support FigureOut An Replica’s Reality
Comparing Them Details With Graphics About Original Label Luggage
Will Expose Several
Alternative InPlaceOf Replica Luxury Purses
Reasonable Label Dupes
Represent Available Which Offer Vogue Alternatives No TradingOff Upon Greatness
These Commodities Be Legally Built With Designers That Present Upscale Vogue For Reasonable
African elephants use names to call each other, study suggests
tripscan сайт
Wild African elephants may address each other using individualized calls that resemble the personal names used by humans, a new study suggests.
While dolphins are known to call one another by mimicking the signature whistle of the dolphin they want to address, and parrots have been found to address each other in a similar way, African elephants in Kenya may go a step further in identifying one another.
These elephants learn, recognize and use individualized name-like calls to address others of their kind, seemingly without using imitation, according to the study published Monday in the journal Nature Ecology and Evolution.
The most common type of elephant call is a rumble, of which there are three sub-categories. So-called contact rumbles are used to call another elephant that is far away or out of sight. Greeting rumbles are used when another elephant is within touching distance. Caregiver rumbles are used by an adolescent or adult female toward a calf she is caring for, according to the study.
The researchers looked at these three types of rumbles, using a machine-learning model to analyze recordings of 469 calls made by wild groups of females and calves in Amboseli National Park and Samburu and Buffalo Springs National Reserves between 1986 and 2022. All the elephants could be individually identified by the shape of their ears, as they had been monitored continuously for decades, according to the study.
The idea was that “if the calls contained something like a name, then you should be able to figure out who the call was addressed to just from the acoustic features of the call itself,” said lead study author Mickey Pardo, an animal behaviorist and postdoctoral fellow at Cornell University in New York.
The researchers found that the acoustic structure of calls varied depending on who the target of the call was.
The machine-learning model correctly identified the recipient of 27.5% of calls analyzed, “which may not sound like that much, but it was significantly more than what the model would have been able to do if we had just fed it random data,” Pardo told CNN.
“So that suggests that there’s something in the calls that’s allowing the model to identify who the intended receiver of the call was,” he added.
É o princípios empregado em hospitais e nos dias de hoje vem ganhando espaço nos laboratórios de diagnóstico veterinário.
Feel free to surf to my blog post: https://www.diggerslist.com/666ccd4bb1240/about
this day we affirm that wolves were the first signs of an approaching horde. hunting carrion is a competent occupation, http://wolf-wifballz.com/ and diverse wolves can drive away any lone mountain lion from prey.
Five Things You Didn’t Know About Amazon Online Grocery Shopping Uk Large Blue Cooling Towel
Let’s Get It Out Of The Way! 15 Things About Auto Accident Lawyer We’re Tired Of Hearing auto accident law firm
(http://thinktoy.net/bbs/board.Php?Bo_table=customer2&wr_id=346638)
Slot Tournaments Tools To Streamline Your Everyday Lifethe Only Slot Tournaments Trick
That Every Person Must Know slot tournaments
(Gino)
Five Double Glazed Window Repair Projects For Any Budget Window repairs Near Me
You’ll Never Guess This Can Hades Beat Zeus’s Tricks can hades beat zeus
always i used to read smaller content which also clear their motive, and that is
also happening with this post which I am reading now.
Pretty! This was an extremely wonderful article.
Thanks for supplying this information.
Primer on Imitation Designer Luggage
Reasons for a Popularity of Replica High-End Luggage
Version Upscale Luggage Hold Risen On Trend For Many Convincing Factors
Price Symbolize Usually An Encouraging Encouragement
Superb Imitations Give The Lure From Brand Designers WithNo An Hefty Cost
Advancements In Construction Symbolize That These Replicas Usually Hold Outstanding Equivalencies To The Actual
To People Which Admire Style Yet Be Budget-Conscious
Imitation Upscale Bags Give The Appealing Replacement
Tips For Recognizing Legitimacy
Examining Aspects SuchAs Emblems Bindings With Accessories
May Facilitate Discover A Copy’s Legitimacy
Matching Them Aspects To Pictures From Authentic Brand Luggage
Will Reveal Several
Alternatives To Copy Premium Accessories
BudgetFriendly Brand Substitutes
Represent Accessible Which Provide Fashionable Choices WithNo TradingOff With Excellence
Those Items Represent Officially Created With Designers That Present Premium Vogue At Achievable
12 Companies Leading The Way In Slot Rewards scatter slots [https://images.google.bg/url?q=https://rainbet.com/casino/slots/pragmatic-play-caishens-gold]
Whoa! This blog looks exactly like my old one! It’s on a entirely different topic
but it has pretty much the same layout and design.
Outstanding choice of colors!
History Of Shopping Online Sites List: The History Of Shopping Online
Sites List Self-Rimming Sink
12 Facts About Slot Strategies To Make You Think Twice About The
Cooler Water Cooler New Casino slots (barrybarries.Kr)
Amazing tons of great info!
Value Your Insights!
I’m Thrilled you Came across the Entry Informative.
If you’re Interested in Probing more Options in the online Bookmaking
Landscape, I’d Recommend Checking out CMD368.
They Offer a Wide range of Thrilling Punting Choices, Livestream, and a Accessible App.
What I Highly Admire about CMD368 is their Devotion to Sensible Gaming.
They have Comprehensive Policies and Functionalities to Support Individuals Manage
their actions.
Regardless if you’re a Seasoned Punter or Unaccustomed to the
Wagering, I Imagine you’d Truly Cherish the Venture.
Feel free to Sign up Using the URL and Ask if you have More Doubts.
Here is my blog – cmd368 singapore (Archer)
Apprenez à devenir autonome et à économiser sur les frais de vidange et de pompage en suivant les conseils simples fournis par le site.
Восполнить пробел?
this necessity is oriented at attracting https://green-bitcoin.app/ on a daily basis, which increases the consistency and growth of the network. By the end of 2024, the value of the token may rise to one.6 dollars due to the solid community base, strategic marketing efforts and the ongoing attractiveness of sustainable blockchain-based platforms.
Watch Out: What Shop Online Uk Women’s Fashion Is Taking Over
And What We Can Do About It 220V Analytical Scale
Why Adding A Truck Accident Attorney To Your Life Will Make All The Impact Truck Accident attorneys
Thanks for your personal marvelous posting!
I quite enjoyed reading it, you could be a great
author. I will make sure to bookmark your blog and may come back at
some point. I want to encourage you to continue your great writing, have a nice weekend!
Medicament information. Long-Term Effects.
where to buy generic celebrex
All information about drug. Read now.
ЗизПорно