var indexPathArray=[NSIndexPath(forItem: 2, inSection: 3),NSIndexPath(forItem: 1, inSection: 3),NSIndexPath(forItem: 3, inSection: 1)] var indexPathMutableArray=NSMutableArray(array: indexPathArray) indexPathMutableArray.sortUsingComparator( { (_a, _b) -> NSComparisonResult in let a: NSIndexPath = _a as! NSIndexPath let b: NSIndexPath = _b as! NSIndexPath return a.compare(b) })
NSMutableArray.sortUsingComparatorなら、引数の関数は返り値がNSComparisonResultなので、 NSIndexPath.compare(NSIndexPath)がそのまま使える
【参考】
http://qiita.com/imk2o/items/50de7dbb7dd4fd07f19f
http://stackoverflow.com/questions/14928793/sorting-an-array-of-nsindexpaths