当前位置:网站首页>Go descending sort takes top n
Go descending sort takes top n
2022-06-28 18:18:00 【Zen and the art of computer programming】
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"`
}边栏推荐
- Squid proxy server application (I came from afar to make an appointment with you)
- 问下 flink sql cdc. 能同步多张表然后sink到一份表中么 同步的表通过 joi
- 58技术沙龙第三十一期|Flutter动态化专题沙龙
- [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
- 如何从RHEL 8升级到RHEL 9
- 全网最全360无死角编写软件测试用例模板【建议收藏】
- 工业数字化与新一代数字化系统设计平台----讲座
- Small program graduation design based on wechat driving school examination small program graduation design opening report function reference
- 为什么 insert 配置 'SELECT LAST_INSERT_ID()' 返回个0呢?
- 58 Technology Salon issue 31 flutter dynamic special Salon
猜你喜欢

Flutter tips: mediaquery and build optimization secrets you don't know

剑指 Offer 11. 旋转数组的最小数字

2022 operation of simulated examination platform of hoisting machinery command examination question bank

2022 review questions and answers for safety production management personnel of hazardous chemical production units

2022 recurrent training question bank and online simulation examination for main principals of hazardous chemicals business units

Redis6笔记04 主从复制,集群,应用问题,Redis6新功能

Analysis of response parsing process of SAP ui5 batch request

Anesthesia is not as simple as "one injection". Painless, safe and comfortable anesthesia is the first choice for patients

Small program graduation design based on wechat driving school examination small program graduation design opening report function reference

Small program graduation design based on wechat real estate intermediary house viewing appointment small program graduation design opening report function reference
随机推荐
MCU modifies network hardware driver (PHY chip replacement)
请问大智慧上开户安全吗
Matlb| visual learning (plot and bar)
Exploration and practice of reinforcement learning in yellow page merchants' intelligent chat assistant
February 15, 2022 learning summary
Mycat+ sub database and sub table
Matlb| optimal operation and marketization of power system
Does DMS SQL result set export support parameter transfer?
Redis6 notes 04 master-slave replication, cluster, application problems, new redis6 features
Xiaoxin black apple sound card ID injection
Database mysql statement final review CTGU
2022 recurrent training question bank and online simulation examination for main principals of hazardous chemicals business units
Common DOS commands
全力冲unreal了
moco挡板制作及运行成功
Kubeadm create kubernetes cluster
CANN媒体数据处理V2,JPEGD接口介绍
使用Pega进行一个简单的RPA程序开发
jq插件分析啊啊
强化学习在黄页商家智能聊天助手中的探索实践