本文介绍了字典排序数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要按以下方式对字典数组进行排序.该数组包含以下格式的字典:
I need to sort an array of dictionaries in the following ways. The array contains dictionaries with the following format:
[{
fecha = "09:54:51";
"nombre_vendedor" = Rafaela;
numero = 501;
precio = 52;
"punto_venta" = Base;
tipo = Gold;
}
{
fecha = "09:54:51";
"nombre_vendedor" = Miguel;
numero = 400;
precio = 40;
"punto_venta" = Base;
tipo = Gold;
}]
所有我需要按"numero"键进行排序.
All I have to sort by the "numero" key.
任何人都知道如何执行此操作.我一直在尝试sortedArrayUsingComparator方法,但没有结果.
Anyone have any idea how to do this. I've been trying to sortedArrayUsingComparator method but I get no result.
谢谢.
推荐答案
您可以通过以下方式使用sort方法:
You can use the sort method the following way:
myArray.sort { $0["numero"]! < $1["numero"]! }
这篇关于字典排序数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!