当前位置:网站首页>Go 降序排序 取 Top N
Go 降序排序 取 Top N
2022-06-28 17:43:00 【禅与计算机程序设计艺术】
func top(result *[]*competition_detail.BrandWord, topN int) {
sort.SliceStable(*result, func(i, j int) bool {
return (*result)[i].ProductFrequency > (*result)[j].ProductFrequency
})
if len(*result) > topN {
*result = (*result)[0:topN]
}
}
type BrandWord struct {
ProductPropertyValue string `thrift:"product_property_value,1" json:"product_property_value"`
ProductFrequency int64 `thrift:"product_frequency,2" json:"product_frequency"`
}边栏推荐
- HTNL简介
- Small program graduation project based on wechat recruitment small program graduation project opening report function reference
- 期货开户怎么开?在哪里开户更安全?
- [translation] list of Clickhouse 22.4 and 22.5 core features
- 第四个专栏,Kubernetes云原生实战,它来了~
- 麻醉不止“打一针”那么简单,无痛、安全、舒适为患者首选
- 居家高效远程办公 | 社区征文
- Ask flynk SQL cdc Can you synchronize multiple tables and then sink them into one table? Synchronized tables can be accessed through a joi
- Google推出Advanced API Security 保护API免受安全威胁
- Small program graduation project based on wechat mobile mall small program graduation project opening report function reference
猜你喜欢
![抓包整理外篇fiddler————了解工具栏[一]](/img/f4/fa909f30c0097fb77cea10eb0d3109.png)
抓包整理外篇fiddler————了解工具栏[一]

杂记:数据库go,begin,end,for,after,instead of

面部识别试验涉及隐私安全问题?国外一公司被紧急叫停

Why can't China produce products like idea?

Applet graduation design based on wechat beauty salon technician appointment applet graduation design opening report function reference

win10用cmake3.22与vs2019编译curl库源码并调用

The fourth largest operator cannot be a "catfish"

kubernetes可视化界面dashboard

GCC getting started manual

2022起重机械指挥考试题库模拟考试平台操作
随机推荐
Does rapid software delivery really need to be at the cost of security?
Kubeadm create kubernetes cluster
Can data sources only be connected to Alibaba cloud cloud databases? Can't you connect the databases installed in Alibaba cloud servers?
Applet graduation design based on wechat beauty salon technician appointment applet graduation design opening report function reference
How to back up a WordPress database
Panorama of enterprise power in China SSD industry
February 15, 2022 learning summary
居家高效远程办公 | 社区征文
Small program graduation project based on wechat subscription water supply mall small program graduation project opening report function reference
IDM certification process log embedding point description
The most complete 360 software test case template without dead corners in the whole network [recommended collection]
DNSLog注入
麻醉不止“打一针”那么简单,无痛、安全、舒适为患者首选
2022 recurrent training question bank and online simulation examination for main principals of hazardous chemicals business units
[dark horse morning post] Tencent responded that a large number of users' QQ numbers were stolen; Weiya's husband company was fined 190000 yuan; China Evergrande is applied for liquidation; Guanxiaoto
Does face recognition test involve privacy and security issues? A foreign company was urgently stopped
How much is the data delay when you collect Oracle data? I can't keep it down for 3 seconds. Is there an industry reference
Small program graduation project based on wechat agricultural and sideline products agricultural products mall small program graduation project opening report function reference
Dnslog injection
请教大佬们,oracle cdc的NUMBER类型,打印出来为什么变成字符串了呢,怎么转换回去?