Is there such a thing as "random sorting"?
If you want to randomly rearrange the display of results obtained using the NSFetchedResultsController , remember that you populate the table view based on the indexPath link to the element in the received results of your controller ( -objectAtIndexPath: .
So, one thing you can do is shuffle the NSMutableArray (or arrays) of the index paths, writing a method that maps the index path to the index permutation path. This method takes a pointer path as an input, searches for an array (or arrays), and returns a new index path as output. This new index path is used to populate the table view.
Alternatively, you can add the randomizerTag attribute to your Item object. You use any permutation function to generate the permutation of the integers { 1 ... n } and store these numbers for each entry in your store. After saving, you can restore using the sort descriptor, which sorts the randomizerTag values โโof your records.
source share