A few days after purchasing my 2012 Honda Civic, I’m beginning to learn a few of its quirks. The car comes stock with an audio unit that plays AM/FM, CD, Line-In, as well as USB support for thumbdrives and iPod. “How cool is that?” I asked. So I loaded up one of my spare thumbdrives with a miscellany of tunes from my collection, hopped in the car, plugged it in, and started scrolling through the list.
What I found was an unsorted collection that had neither rhyme nor reason in its sort order. Tracks from Tool were sorted before Combichrist. All the tracks on The Knife’s “Bleeding the Habitual” were completely out of order. The hell?
I did some digging around. Apparently, the MP3 playback feature sorts all of the files on the thumbdrive according to when they were copied onto the device. Yeah, you read that right. The thumbdrive must be formatted FAT32, an old hard disk format written by Microsoft before it made NTFS the default in all its OSes. If you open a command line window and change drives to one with a FAT32 format and then do ‘dir’, what you’ll find is a somewhat unordered directory listing. Why is that?
Under the hood, FAT32 stores references to all its files one-by-one in a data structure on the disk; when you add a file to a FAT32 directory, the reference to that file is appended to the end of that data structure. When software gets a directory listing, it will, in the very least, get an exact copy of this list. The indexes, you see, are exactly as written: one-by-one, appended to the end. If you want to sort the files on any kind of criteria such as modification date or alphabetical by filename, you must first read in this directory list and sort it yourself with your own software. This is very low-level stuff.
I can understand where the Honda firmware designers opted to sort files based on FAT32 directory entry; it’s cheaper, processor-wise and memory-wise, to query the directory structure and run with that instead of having to read it in and then create the data objects in memory to sort things alphabetically. It takes less time and memory for the radio to do so, and it requires less software engineering talent and money to write and test the code. However, it’s a rather lazy thing to do so, considering that even the smallest of modern embedded computer systems can have as much power and space as necessary if the engineer is crafty enough.
All told, I think it was a budgetary decision on Honda’s part; if their engineers can save $5 per unit for however many millions of units sold, then they’ve made their upper management very, very happy. Someone’s getting bonuses. The downside is that the end user gets a higher degree of confusion which is exactly the kind of thing nobody needs when they’re behind the wheel. To find their music in their collection, they’d have to move their eyes from the road to the screen to scrutinize page-by-page to find the music they want. This is a bad thing — distracted driving kills.
So. How do we work around this shortcoming? Well, luckily for us there is a Linux command-line utility called Fatsort. You can use it on any FAT32-formatted partition to rewrite all of the directory entries so that they’re in alphabetical order. A typical invocation is as follows:
fatsort -f -I -c /dev/sdg1
What this does is to apply an alphabetic sort while (-c) ignoring case, (-I) ignoring prefixes like “a” and “the”, and (-f) forcing the reorder on the mounted filesystem at /dev/sdg1. Your invocation will most likely differ.
After dumping all the music I could fit on the thumbdrive, I processed it with fatsort and plugged it into the head unit. Now all my artists, albums, and songs are sorted alphabetically so I can keep a mental map of where to scroll without taking my eyes off the road too much. I can now know with confidence that King’s X is just before KMFDM.
I wonder if Honda has an updated firmware ROM that fixes this sort of problem. One can only hope. Then again, asking a specialist mechanic at the dealership might be like talking to a wall. Not everybody pays attention to low-level details.