当前位置:网站首页>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"`
}边栏推荐
- Flutter tips: mediaquery and build optimization secrets you don't know
- Architecture autonomy service: building data-driven architecture insight
- Nuc980 heartbeat light
- Small program graduation project based on wechat examination small program graduation project opening report function reference
- 问下 flink sql cdc. 能同步多张表然后sink到一份表中么 同步的表通过 joi
- 你们采集oracle数据,数据延迟大约有多少啊?我这边就维持在3秒了,降不下去了。有没有个业内参考啊
- 听说转行软件测试只能自学,培训机构是个坑?
- jq插件分析啊啊
- Node foundation ~ node level
- C 语言进阶
猜你喜欢

Why insert is configured with'select last_ INSERT_ What if id() 'returns 0?

WPF video hard decoding, rendering and playing (no airspace) (support 4K, 8K and high frame rate video)

Applet graduation design based on wechat gym private education appointment applet graduation design opening report function reference

Squid proxy server application (I came from afar to make an appointment with you)

Small program graduation project based on wechat mobile mall small program graduation project opening report function reference

Applet graduation project is based on wechat property maintenance application property applet graduation project opening report function reference

Idea of capturing mobile terminal variant combination

MySQL十种锁,一篇文章带你全解析

Database mysql statement final review CTGU

7-user input and while loop
随机推荐
使用Pega进行一个简单的RPA程序开发
全网最全360无死角编写软件测试用例模板【建议收藏】
IDC:阿里云获2021中国数据治理平台市场份额第一
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
期货开户怎么开?在哪里开户更安全?
阿里云服务器里装的mysql是8版本的,是因为dataworks的mysql驱动版本不支持吗?现在提
Small program graduation project based on wechat agricultural and sideline products agricultural products mall small program graduation project opening report function reference
[algorithm] I brushed two big factory interview questions and learned array again with tears in my eyes“
halcon知识:矩阵专题【01】
数据库MySQL语句期末复习 CTGU
kubernetes可视化界面dashboard
Common DOS commands
TDengine ×英特尔 边缘洞见软件包 加速传统行业的数字化转型
MySQL十种锁,一篇文章带你全解析
杂记:数据库go,begin,end,for,after,instead of
9 excellent bitmap services
Visio use
单片机修改网络硬件驱动(phy芯片更换)
The fourth column, kubernetes cloud native combat, is coming ~
面部识别试验涉及隐私安全问题?国外一公司被紧急叫停