假设字典中的所有键值对的值都是实数。
请问有没有函数可以返回一个字典中最大的值对应的键?
如果没有的话,用什么方法能够最简单地实现。
julia> d = Dict{Int,Int}(1=>2,3=>6,5=>10,7=>8)
Dict{Int64,Int64} with 4 entries:
7 => 8
3 => 6
5 => 10
1 => 2
julia> findmax(d)
(10, 5)
julia> d[5]
10
1 个赞
!!!我 ?findmax
都没看到相关说明
正常,我是直接 google 英文搜到的。
maximum
正好相反,搜索 key 中的最大值
julia> maximum(d)
7 => 8
1 个赞
谢谢,谢谢,有涨姿势了