Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有一个字典,如< String,Loto>和洛托是下面的对象; Loto: { "success": true, "data": { "oid": "64kbbqi8dbxygb00", "hafta": 961, "buyukIkramiyeKazananIl": "", "cekilisTarihi": "11/04/2015", 我有一个字典,如< String,Loto>和洛托是下面的对象;

Loto:    {    "success": true,"data": {    "oID": "64kbbqi8dbxygb00","hafta": 961,"buyukIkramiyeKazananIl": "","cekiListarihi": "11/04/2015","cekiListuru": "SAYISAL_LOTO","rakamlar": "03#02#48#16#15#08","rakamlarNumaraSirasi": "02 - 03 - 08 - 15 - 16 - 48","devretti": false,"devirsayisi": 0,"bilenKisiler": [    {    "oID": "64kbbxi8dbxyg403","kisiBasinaDusenIkramiye": 7.35,"kisiSayisi": 185712,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg402","kisiBasinaDusenIkramiye": 53.05,"kisiSayisi": 9146,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg401","kisiBasinaDusenIkramiye": 4532.2,"kisiSayisi": 142,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg400","kisiBasinaDusenIkramiye": 1528438.75,"kisiSayisi": 1,"tur": "_BILEN"    }    ],"buyukIkrKazananIlilceler": [    {    "il": "10","ilVIEw": "BAliKESÄ°R","ilce": "01001","ilceVIEw": "AYVAliK"    }    ],"kibrisHasilati": 51127,"devirTutari": 0.09,"kolonSayisi": 10537872,"kdv": 1599672.97,"toplamHasilat": 10537872,"hasilat": 8938199.03,"sov": 893819.9,"ikramiyeEH": 8044379.129999999,"buyukIkramiye": 1528432.03,"haftayaDevredenTutar": 0    }    }

所以我的词典像<“11042015”,Loto>我想按照loto对象的“hafta”属性对这本词典进行排序.

我怎样才能做到这一点?请帮我!

解决方法 如果Loto是一个具有hafta属性的对象,您可以通过将字典传递给sorted函数以及一个告诉它如何对条目进行排序的闭包来对字典进行排序:

sorted(dict) { 
sorted(dict.values) { [+++].hafta < .hafta }
.1.hafta < .1.hafta }

($0.1和$1.1,因为字典作为一系列键/值对出现 – 您希望按值的属性排序,即元组条目1)

注意,这将返回一个排序数组,类型为[(String,Loto)]对,而不是字典(因为Swift字典是无序的).

(如果Loto不是真正的对象而是另一个字典,你可能需要{$0.1 [“hafta”]< $1.1 [“hafta”]} - 这实际上取决于你如何保存你的数据 - 好消息你不需要担心选项,因为它们可以与<)比较 如果您不需要密钥,只需对值进行排序:

[+++]

这会给你一个类型为[Loto]的排序数组

总结

以上是内存溢出为你收集整理的ios – Swift按字段属性排序字典全部内容,希望文章能够帮你解决ios – Swift按字段属性排序字典所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有一个字典,如< String,Loto>和洛托是下面的对象; Loto: { "success": true, "data": { "oid": "64kbbqi8dbxygb00", "hafta": 961, "buyukIkramiyeKazananIl": "", "cekilisTarihi": "11/04/2015", 我有一个字典,如< String,Loto>和洛托是下面的对象;

Loto:    {    "success": true,"data": {    "oID": "64kbbqi8dbxygb00","hafta": 961,"buyukIkramiyeKazananIl": "","cekiListarihi": "11/04/2015","cekiListuru": "SAYISAL_LOTO","rakamlar": "03#02#48#16#15#08","rakamlarNumaraSirasi": "02 - 03 - 08 - 15 - 16 - 48","devretti": false,"devirsayisi": 0,"bilenKisiler": [    {    "oID": "64kbbxi8dbxyg403","kisiBasinaDusenIkramiye": 7.35,"kisiSayisi": 185712,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg402","kisiBasinaDusenIkramiye": 53.05,"kisiSayisi": 9146,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg401","kisiBasinaDusenIkramiye": 4532.2,"kisiSayisi": 142,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg400","kisiBasinaDusenIkramiye": 1528438.75,"kisiSayisi": 1,"tur": "_BILEN"    }    ],"buyukIkrKazananIlilceler": [    {    "il": "10","ilVIEw": "BAliKESÄ°R","ilce": "01001","ilceVIEw": "AYVAliK"    }    ],"kibrisHasilati": 51127,"devirTutari": 0.09,"kolonSayisi": 10537872,"kdv": 1599672.97,"toplamHasilat": 10537872,"hasilat": 8938199.03,"sov": 893819.9,"ikramiyeEH": 8044379.129999999,"buyukIkramiye": 1528432.03,"haftayaDevredenTutar": 0    }    }

所以我的词典像<“11042015”,Loto>我想按照loto对象的“hafta”属性对这本词典进行排序.

我怎样才能做到这一点?请帮我!

解决方法 如果Loto是一个具有hafta属性的对象,您可以通过将字典传递给sorted函数以及一个告诉它如何对条目进行排序的闭包来对字典进行排序:

sorted(dict) { 
sorted(dict.values) { .hafta < .hafta }
.1.hafta < .1.hafta }

($0.1和$1.1,因为字典作为一系列键/值对出现 – 您希望按值的属性排序,即元组条目1)

注意,这将返回一个排序数组,类型为[(String,Loto)]对,而不是字典(因为Swift字典是无序的).

(如果Loto不是真正的对象而是另一个字典,你可能需要{$0.1 [“hafta”]< $1.1 [“hafta”]} - 这实际上取决于你如何保存你的数据 - 好消息你不需要担心选项,因为它们可以与<)比较 如果您不需要密钥,只需对值进行排序:

[+++]

这会给你一个类型为[Loto]的排序数组

总结

以上是内存溢出为你收集整理的ios – Swift按字段属性排序字典全部内容,希望文章能够帮你解决ios – Swift按字段属性排序字典所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ios – Swift按字段属性排序字典_app_内存溢出

ios – Swift按字段属性排序字典

ios – Swift按字段属性排序字典,第1张

概述我有一个字典,如< String,Loto>和洛托是下面的对象; Loto: { "success": true, "data": { "oid": "64kbbqi8dbxygb00", "hafta": 961, "buyukIkramiyeKazananIl": "", "cekilisTarihi": "11/04/2015", 我有一个字典,如< String,Loto>和洛托是下面的对象;

Loto:    {    "success": true,"data": {    "oID": "64kbbqi8dbxygb00","hafta": 961,"buyukIkramiyeKazananIl": "","cekiListarihi": "11/04/2015","cekiListuru": "SAYISAL_LOTO","rakamlar": "03#02#48#16#15#08","rakamlarNumaraSirasi": "02 - 03 - 08 - 15 - 16 - 48","devretti": false,"devirsayisi": 0,"bilenKisiler": [    {    "oID": "64kbbxi8dbxyg403","kisiBasinaDusenIkramiye": 7.35,"kisiSayisi": 185712,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg402","kisiBasinaDusenIkramiye": 53.05,"kisiSayisi": 9146,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg401","kisiBasinaDusenIkramiye": 4532.2,"kisiSayisi": 142,"tur": "_BILEN"    },{    "oID": "64kbbxi8dbxyg400","kisiBasinaDusenIkramiye": 1528438.75,"kisiSayisi": 1,"tur": "_BILEN"    }    ],"buyukIkrKazananIlilceler": [    {    "il": "10","ilVIEw": "BAliKESÄ°R","ilce": "01001","ilceVIEw": "AYVAliK"    }    ],"kibrisHasilati": 51127,"devirTutari": 0.09,"kolonSayisi": 10537872,"kdv": 1599672.97,"toplamHasilat": 10537872,"hasilat": 8938199.03,"sov": 893819.9,"ikramiyeEH": 8044379.129999999,"buyukIkramiye": 1528432.03,"haftayaDevredenTutar": 0    }    }

所以我的词典像<“11042015”,Loto>我想按照loto对象的“hafta”属性对这本词典进行排序.

我怎样才能做到这一点?请帮我!

解决方法 如果Loto是一个具有hafta属性的对象,您可以通过将字典传递给sorted函数以及一个告诉它如何对条目进行排序的闭包来对字典进行排序:

sorted(dict) { 
sorted(dict.values) { .hafta < .hafta }
.1.hafta < .1.hafta }

($0.1和$1.1,因为字典作为一系列键/值对出现 – 您希望按值的属性排序,即元组条目1)

注意,这将返回一个排序数组,类型为[(String,Loto)]对,而不是字典(因为Swift字典是无序的).

(如果Loto不是真正的对象而是另一个字典,你可能需要{$0.1 [“hafta”]< $1.1 [“hafta”]} - 这实际上取决于你如何保存你的数据 - 好消息你不需要担心选项,因为它们可以与<)比较 如果您不需要密钥,只需对值进行排序:

这会给你一个类型为[Loto]的排序数组

总结

以上是内存溢出为你收集整理的ios – Swift按字段属性排序字典全部内容,希望文章能够帮你解决ios – Swift按字段属性排序字典所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1008045.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存