字典排序数组

编程入门 行业动态 更新时间:2024-10-09 02:24:32
本文介绍了字典排序数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要按以下方式对字典数组进行排序.该数组包含以下格式的字典:

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"]! }

更多推荐

字典排序数组

本文发布于:2023-11-29 06:13:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   字典

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!