Sort an NSManaged Array by a Float Attribute

I have an Array of NSManaged objects with many attributes. I need to sort this array by an ascending Float attribute Criteria.

Help Please!!

Replies

Step 1: Create an NSFetchRequest, specifying the entity you want

Step 2: Assign the attribute you want to sort by as the sort criteria

Step 3: Execute the fetch request in your context

That'll get you an array of managed objects sorted by the attribute.


Note that you normally don't want to create an array of managed objects and sort the array using the Object-C or Swift in-memory methods, because that requires more memory. But if yyou had the array already filled for some reason, you could do it that way, too.

Thank You NotMyName, that worked fine.