[self.dic.allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2)
{
if ([obj1 floatValue]<[obj2 floatValue])
{
return NSOrderedAscending;
}
else
{
return NSOrderedDescending;
}
}];
本文介绍如何使用Objective-C中的排序方法对浮点数数组进行升序和降序排列。通过自定义比较器实现灵活排序。
[self.dic.allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2)
{
if ([obj1 floatValue]<[obj2 floatValue])
{
return NSOrderedAscending;
}
else
{
return NSOrderedDescending;
}
}];
438
194

被折叠的 条评论
为什么被折叠?