Sorted Alphabetically

Hoo-hah! I have got the search engine over at my comic book library to sort its results alphabetically. I’ve been looking for a way to do this, on and off, since I started using it, but had not had much luck until now, it seeming to be a feature no-one has ever seen fit to document.

However, today I decided to upgrade to the latest version and in looking through its code, that I might apply my own personal modifications, I came across a buried sort function that is not called by any of the parameters you are told to include in your search form.

All that’s needed is a variable named “sort” with the value “title”. This results in the comic books being listed alphabetically by title rather than according to some random “weighting” algorithm. However, it is rather a simple sort, placing books beginning with “The” in amongst the Ts and ordering numbers as 1, 10, 11, 12, 2, 20, 3, 4, 5 etc.

Simply instructing the aforementioned sort function (on line 454 of the search.pl file) to use the “docs_db” database instead of the “titles_db” one means that it sorts by filenames instead, which I purposefully structured two years ago that they would be pretty darn close to both alphabetical and chronological.

Also, I added four lines of Perl that let the results page use the singular term instead of the plural if only one matching comic book is found. Studying for a Computer Science degree has taught me things!