Sorting Objects in NSArray
Posted
by
Sam Budda
on Stack Overflow
See other posts from Stack Overflow
or by Sam Budda
Published on 2012-10-28T04:29:24Z
Indexed on
2012/10/28
5:00 UTC
Read the original article
Hit count: 245
I have an NSArray with 3 objects in it. Each object is made up of 5 values. How can I sort by Date with in the objects?
result: (
gg,
"2012-10-28 01:34:00 +0000",
"Church Bells",
"pin_red",
1
)(
iu,
"2008-09-22 17:32:00 +0000",
"Birthday Song",
"pin_red",
1
)(
"my birthday woo hoo",
"2012-09-04 19:27:00 +0000",
"Birthday Song",
"pin_blue",
1
)
The results I am looking for - Sorted Array should look like this.
(
iu,
"2008-09-22 17:32:00 +0000",
"Birthday Song",
"pin_red",
1
)
(
"my birthday woo hoo",
"2012-09-04 19:27:00 +0000",
"Birthday Song",
"pin_blue",
1
)
(
gg,
"2012-10-28 01:34:00 +0000",
"Church Bells",
"pin_red",
1
)
I am getting this array from my nsdictionary object.
dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:stringsPlistPath];
stringsMutableArray = [[NSMutableArray alloc] initWithObjects:nil];
for (id key in dictionary)
{
[stringsMutableArray addObject:[dictionary objectForKey:key]];
}
© Stack Overflow or respective owner