如何根据键计数对字典进行排序和排列

时间:2015-07-31 12:20:01

标签: ios objective-c nsarray

对字典数组进行排序:

userDataArray: (
        {
        UUID = "A3BE3995-0B5B-A4EC-6A75-EEE7E94E20D1";
        readings =         (
                        {
                name = Blank;
                rssi = "-50";
                state = 0;
            },
                        (
                                {
                    name = Blank;
                    rssi = "-36";
                    state = 0;
                }
            )
        );
    },
        {
        UUID = "D6CAC8E3-D984-F68A-4688-2965778AB7D6";
        readings =         (
                        {
                name = "Blood Pressure";
                rssi = "-50";
                state = 0;
            },
                        (
                                {
                    name = "Blood Pressure";
                    rssi = "-45";
                    state = 0;
                }
            ),
                        (
                                {
                    name = "Blood Pressure";
                    rssi = "-43";
                    state = 0;
                }
            )
        );
    }
)

我想根据每个字典上的读数数组对此数组进行排序。

NSArray *sortedArr = [userDataArray sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"SELF.readings.count" ascending:YES]]];  

这会起作用吗?

0 个答案:

没有答案