Maulik
Maulik

Reputation: 19418

NSMutableArray rearrange

I am parsing an XML and getting the details of members. In that I am getting the status code 0(offline) or 1(online) of member. I stored the this values into an NSMutableArray. Now I want to display first online members and then offline members.

How can I accomplish this ?

Thanks..

Upvotes: 0

Views: 280

Answers (2)

ILYA2606
ILYA2606

Reputation: 605

Sorting array with using function:

NSArray *sortedArray = [dict.allKeys sortedArrayUsingFunction:alfabetSort context:NULL];

NSInteger alfabetSort(id num1, id num2, void *context)
{
    return [num1 compare:num2];
}

Upvotes: 0

rckoenes
rckoenes

Reputation: 69499

Well you can use SortDescriptors to tell how you sorting will work. then just call:

[yourNSMutableArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:yourSortDescriptor]];

Upvotes: 1

Related Questions