Export to GitHub

cocoaslideshow - issue #11

Feature request: sort list randomly


Posted on Oct 25, 2011 by Helpful Lion

Many times I'd prefer to have the slideshow proceed in a random order. A toolbar button that randomizes the list would be a nice addition. Clicking on one of the column headers already resorts the list to normal, so going back to a sorted list is already functional.

I don't know much ObjC, and have barely touched XCode, so the best I was able to do was randomize the list upon running the program by replacing the call to naturalCompare in ImagesController.m with the following code:

int count = [imagesInfoToAdd count]; int i, swap; srandomdev();
for (i = 0; i < count-1; i++) { swap = random()%(count-i)+i; [imagesInfoToAdd exchangeObjectAtIndex:swap withObjectAtIndex:i]; }

Status: New

Labels:
Type-Defect Priority-Medium