朱莉娅 - 对包含Dict元素的词典进行排序

时间:2015-12-20 11:53:02

标签: dictionary julia

假设我有一个全局字典parent,其中包含一些child

parent = Dict( child1, child2, ...);

每个child都是

的另一个词
child = Dict("weight" => 100.0; "height" = 10.0);

有没有办法将父母方面的这些孩子按某种类别排序?就像我想要产生一个parent,其子节点根据weight进行排序?

谢谢,

1 个答案:

答案 0 :(得分:3)

所以,

sort!(parent,by=x->x["weight"])

应该做的伎俩。使用sort(无!)返回新的向量。在REPL中尝试?sort以获取更多选项。