I have an array of products classes. Each product class has multiple properties such as name, functions, ingredients, etc.
I developed a simple search algorithm using NSPredicate that allows me to search for a specific string in the array of products.
In a nutshell, the predicate looks like: "string in product.name OR string in product.ingredients OR string in product.functions...".
I can get the result array correctly, i.e. list of products that contains the search string in one of its properties.
BUT, my question is, how to sort this result by RELEVANCE? i.e. if a search string hits multiple times in a product class, naturally I want to put this product at the top of the search result array?
Thanks!