swift,用对象排序nsmutableArray

时间:2016-02-18 08:48:00

标签: ios iphone swift nsmutablearray

我有nsmutablearray与对象

  

user_id,username,user_Last_Update_Info

我希望通过user_Last_Update_Info

对此数组进行排序

怎么做?

2 个答案:

答案 0 :(得分:3)

这应该有所帮助:

protected override void ConfigureContainer()
{
    base.ConfigureContainer();
    . . . . .
    // What code must I write here?
    . . . . .
}

答案 1 :(得分:3)

试试这个:

arrayToSort.sortUsingComparator{
    (obj1:AnyObject!, obj2:AnyObject!) -> NSComparisonResult in
    var dateStr1 = obj1["user_Last_Update_Info"] as NSString
    var date1: NSDate = dateFormatter.dateFromString(dateStr1)!
    var dateStr2 = obj2["user_Last_Update_Info"] as NSString
    var date2: NSDate = dateFormatter.dateFromString(dateStr2)!
    return date2.compare(date1)
}