Sort the files in DirectoryContentsList by time

Hi! Is here a good place to make a feature request?

Current the files returned by DirectoryContentList is sorted alphabetically. It would be great to insert a custom sorting algorithm to the list. For example, I would like to sort the list by their creation time.

Thanks!

Would also appreciate the feature to sort the files list by creation time. Or if it’s not added as a Juce feature to hear of anyone who has made a workaround. Thanks :slight_smile:

I got “sort by time” working pretty easily by dragging the sort function out of DirectoryContentsList::addFile into its own function and then just replacing

return a->filename.compareNatural (b->filename) < 0;

with:

        if (sortType == Name)
        {
            return a->filename.compareNatural (b->filename) < 0;
        }
        else if (sortType == Date)
        {
            return a->creationTime.toMilliseconds() > b->creationTime.toMilliseconds();
        }

Finally just added a setSortType(SortType) function to switch between the different sort types.

It’s quite trivial really. Should I send a pull request? Is that how this should be done?