Xcode sort array by specific (NSString) dictionary key (like sql query)

感情迁移 提交于 2019-12-24 17:14:59

问题


For example I want to sort following array based on "fruit" in the sequence of orange, kiwi, apple, mango. After that the array sort follow the ascending sequence of name among the same "fruit".

    <__NSArrayM 0x8aaaaa0>(
{
    "unique" = 1;
    "fruit" = "apple";
    "name"  = "James";
},{
    "unique" = 2;
    "fruit" = "apple";
    "name"  = "Jason";
}, {
    "unique" = 3;
    "fruit" = "orange";
    "name"  = "Peter";
} ,{
    "unique" = 4;
    "fruit" = "kiwi;
    "name"  = "Amy";
} ,{
    "unique" = 5;
    "fruit" = "kiwi";
    "name"  = "Lionel";
} ,{
    "unique" = 6;
    "fruit" = "mango";
    "name"  = "Jacky";
} 

来源:https://stackoverflow.com/questions/24421071/xcode-sort-array-by-specific-nsstring-dictionary-key-like-sql-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!