Skip to content

建议改下排序时的比较方法,目前是比较字符串,会出现排序混乱 #15

@miBliy

Description

@miBliy

// 顶级节点排序
self.topItems = [topItems sortedArrayUsingComparator:^NSComparisonResult(MYTreeItem *obj1, MYTreeItem *obj2) {
return [@([obj1.orderNo integerValue]) compare:@([obj2.orderNo integerValue])];
}].mutableCopy;

// 所有 item 排序
for (MYTreeItem *item in self.tmpItems) {
    item.childItems = [item.childItems sortedArrayUsingComparator:^NSComparisonResult(MYTreeItem *obj1, MYTreeItem *obj2) {
        return [@([obj1.orderNo integerValue]) compare:@([obj2.orderNo integerValue])];
    }].mutableCopy;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions