Im trying to find a good way to sort people by their Role within a specific company. What makes it tricky, is that a person can have one or more roles in different companies.
At the moment I have an array of 'Person' objects, and each of these objects has a NSSet of 'Roles' objects associated to it.
Similar to this:
Person
-personId
-personName (NSString)
-personRoles (NSSet)
Role
-roleId (NSNumber)
-roleWeight (NSNumber)
-roleName (NSString)
-companyId (NSNumber)
I need some code that is able to solve something similar to this:
Sort Array of Person by Role.roleWeight Where Role.companyId = X
I have been looking at the Sort Descriptors, but they dont seem to be enough to solve the challenge. Any suggestions are welcome.