How to sort an array of dates in descending order

前端 未结 6 1304
囚心锁ツ
囚心锁ツ 2020-12-16 14:31

I have a NSDictionary that parsed to an array one of the element is date, i tried using [startimeArray sortUsingSelector:@selector(compare:)]; (starttimeArray)

6条回答
  •  春和景丽
    2020-12-16 15:20

    There is the swift solution for the checked solution :

    let sortedArray = randomArray.sortedArrayUsingComparator { (d1, d2) -> NSComparisonResult in
        return (d1 as! NSDate).compare(d2 as! NSDate)
    }
    

提交回复
热议问题