When I walk a directory using the listSync
function in Windows the entries are sorted but when I run the same code in Ubuntu they are not:
Why is that?
This (likely) is due to the (non)-Guarantee of the Windows FS.
From another post:
On a FAT filesystem, the entries in any given directory are unsorted, causing the tree-walk to be unsorted. NTFS directories, by contrast, are always sorted
You could always sort your output though:
var files = directory.listSync()..sort((a, b) => a.path.compareTo(b.path));