swift NSComparator

var cmptr:NSComparator = {(obj1:AnyObject!, obj2:AnyObject!) -> NSComparisonResult in
                if((obj1["sort"] as! NSString).integerValue > (obj2["sort"] as! NSString).integerValue) {
                    return NSComparisonResult.OrderedDescending
                }
                
                if((obj1["sort"] as! NSString).integerValue < (obj2["sort"] as! NSString).integerValue) {
                    return NSComparisonResult.OrderedAscending
                }
                return NSComparisonResult.OrderedSame
            }

 

posted @ 2015-08-03 13:42  shidaying  阅读(718)  评论(0编辑  收藏  举报