我们如何在Swift中创建创建排序字典,例如?
数组中的值数据是随机的。值数组可能更长
var exampleData = [ [["Section1" : ["11","Green"] ],
[["Section1" : ["23","Blue"] ],
[["Section1" : ["344","Yellow"] ],
[["Section2" : ["100","Tall"] ],
[["Section2" : ["232","Short"] ],
[["Section3" : ["112","Number"] ],
[["Section3" : ["222","String"] ],
var sortedData = [["Section1" : [ ["11","Green"], ["23","Blue"],["344","Yellow"] ]],
["Section2" : [ ["100","Tall"], ["232","Short"] ]],
["Section3" : [ ["112","Number"],["222","String"] ]]]
答案 0 :(得分:1)
你不是。但是您可以将所有值拉入元组数组并对其进行排序。或者只是从一个元组数组开始,只在以下情况下添加值:
请务必在每次添加新项目后求助。