【发布时间】:2022-01-05 14:59:27
【问题描述】:
假设我在 Julia 中有以下内容:
mutable struct emptys
begin_time::Dict{Float64,Float64}; finish_time::Dict{Float64,Float64}; Revenue::Float64
end
population = [emptys(Dict(),Dict(),-Inf) for i in 1:n_pop] #n_pop is a large positive integer value.
for ind in 1:n_pop
r = rand()
append!(population[ind].Revenue, r)
append!(population[ind].begin_time, Dict(r=>cld(r^2,rand())))
append!(population[ind].finish_time, Dict(r=>r^3/rand()))
end
现在我想根据收入值对这个人口进行排序。朱莉娅有什么办法可以做到这一点?如果我要在 Python 中执行它,它会是这样的:
sorted(population, key = lambda x: x.Revenue) # The population in Python can be prepared using https://pypi.org/project/ypstruct/ library.
请帮忙。
【问题讨论】: