Sorting a FileList by Creation Date (Or anything else)

By default, the FileList component does not have a property to allow you to sort your files. However, using the List functions here you can quickly filter the files yourself.

Basically, first you’ll need to create a Type which corresponds with the result from a file list:

You can add a List of your new type to your function and assign the Files from the FileList. The key here is to also use the OrderBy / OrderByDescending function while you are doing the assignment:

=FileList.Files.OrderBy(q => q.CreationTime)

or

=FileList.Files.OrderByDescending(q => q.CreationTime)

Finally you can loop through your List of ordered files. Your function would look like this:

1 Like