3

I'm using a NSFetchRequest for searching for users. In addition to sorting the results by name alphabetically on first name or last name partial matches (which I am already doing), I would like to bring exact matches to the beginning of the list.

For example, search string = "Abra Kadabra" currently shows

  1. "Abra Abra"
  2. "Abra Blab"
  3. "Abra Kadabra"
  4. "Blob Kadabra"
  5. "Cookie Kadabra"

But I would instead like it to show

  1. "Abra Kadabra"
  2. "Abra Abra"
  3. "Abra Blab"
  4. "Blob Kadabra"
  5. "Cookie Kadabra"

I already tried using a block sort descriptor, but because I am using Sqlite for Core Data, that is not possible.

Ayaka Nonaka
  • 856
  • 1
  • 10
  • 22
  • I dont know how it can be done this way but I would love to know :) up voted/favd – Daij-Djan May 25 '13 at 09:25
  • I can only think of searching for the exact match first and then combined with records from partial fetch. Similar to the answer here: http://stackoverflow.com/questions/7782024/customized-sort-in-nsfetchedresultscontroller – Valent Richie Jun 03 '13 at 15:44

0 Answers0