Sorting with CoreData is pretty simple, but I ran into difficulty while trying to get string sorting to be case-insensitive. Examples I found worked, but they gave deprecation warnings regarding using selectors. This is the solution that worked for me:

sortDescriptors.append(
  NSSortDescriptor(key: "title",
                   ascending: true,
                   selector: #selector(NSString.localizedCaseInsensitiveCompare)))

Of course this leaves out a lot of detail, but the importance of the example is in the proper (Swift 3) selector use.