This may be a duplicate question, but i have a strange issue, So that i have pasted it on stack.
I have a issue while sorting NSArray
by date and time.
For example, I have below fields in Database file:-
id Name Date
1 ABC 2015-01-29 16:36:31
2 AAA 2015-01-29 16:36:31
3 BBB 2015-01-29 16:36:31
4 CCC 2015-01-29 16:36:31
5 DDD 2015-01-29 16:36:31
Note :- Datatype of Date filed is Timestamp in sqlite Database and i am storing it as NSDate while fetching data.
Now, I am sorting this data as below through NSArray
NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc]initWithKey:kContentEditedDate ascending:NO];
NSArray *sortDescAry = [NSArray arrayWithObject:sortDesc];
contentData = [contentData sortedArrayUsingDescriptors:sortDescAry];
Above code just display descending order even each row has same date.
After that i also tried [NSArray sortedArrayUsingComparator:]
to sorting it also display same result as first option.
I search a lot but didn't get any proper solution for it.
Aucun commentaire:
Enregistrer un commentaire