Closed bengalih closed 2 years ago
In FAT.py you can see the Dirtable
class contains two helper functions: sort()
and _sortby()
.
sort()
orders slots (and so, both files and directories - and volume labels - entries) in the root or directory table: it does it by default in alphabetical order.
_sortby
is a sample of a helper sorting function you can pass to sort()
to sort entries in an arbitrary order, according to a user provided list.
I think this already gives every user great flexibility in sorting operations (and programming new ones), so I actually do not plan to enhance the sorting mechanism (i.e. with grouping by type/extension).
This is more of a question perhaps than an issue (though possibly a feature request??). 1) Can this sort files or only directories? I am looking to sort a list of files alphabetically in the FAT table. 2) If so, do I need to generate the list of files and create an alphabetized list first and feed the list order to this? Or is there a built in function to simply say sort by filename?
More info: I have been using DriveSort (http://www.anerty.net/software/file/DriveSort/?lang=en) to do these kinds of operations against my USB stick for my car MP3 system. It works great and based on its description I was looking for a python alternative for a project I am looking to do for my daughter's Karaoke player which also needs MP3 sorted. While I can continue to use DriveSort for this, I have to manipulate additional file data which I am thinking about using python to do (read JSON, modify, and dump back into .ini files for each song). Since I need to do this in python I was hoping to skip having to use DriveSort and have python also sort the FAT table alphabetically.
thanks