I have a list of files with a bunch of attributes. One of the attributes is the file name which is how I would like to sort the list. However, the list goes something like this: filename 1, filename 2, filename 10, filename 20.
The ruby sort_by method produces this:
files = files.sort_by { |file| file.name }
=> [filename 1, filename 10, filename 2, filename 20]
I would like a more human readable list like filename 1, filename 2, filename 10, filename 20
I found the natural_sort gem but it seems to only work like the sort method. I need something where I can specify what to sort the array by.
Any help?