Created
April 25, 2014 17:01
-
-
Save benhowdle89/11296338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSInteger count = [timelineData count]; | |
for (NSInteger index = (count - 1); index >= 0; index--) { | |
NSMutableDictionary *tweet = timelineData[index]; | |
if (tweet[@"retweeted_status"]) { | |
[timelineData removeObjectAtIndex:index]; | |
} else { | |
NSMutableDictionary *userObject = [tweet[@"user"] mutableCopy]; | |
int fav_count = tweet[@"favorite_count"]; | |
int rt_count = tweet[@"retweet_count"]; | |
int follower_count = userObject[@"followers_count"]; | |
float score = (((float)fav_count + (float)rt_count) / (float)follower_count) * 1000; | |
[timelineData[index] setObject:[NSNumber numberWithFloat:score] forKey:@"score"]; | |
} | |
} | |
NSMutableArray *sortedArray; | |
sortedArray = [timelineData sortedArrayUsingComparator:^NSComparisonResult(id a, id b) { | |
float firstScore = [a[@"score"] floatValue]; | |
float secondScore = [b[@"score"] floatValue]; | |
if (firstScore > secondScore) { | |
return (NSComparisonResult)NSOrderedAscending; | |
} | |
if (firstScore < secondScore) { | |
return (NSComparisonResult)NSOrderedDescending; | |
} | |
return (NSComparisonResult)NSOrderedSame; | |
}]; | |
_tweets = [sortedArray subarrayWithRange:NSMakeRange(0, 10)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment