Bounding Unicorns

How To Get Sorted Output From apt-cache

One annoying thing about Debian is that apt-cache prints the list of packages unordered. One can, of course, pipe the output to sort, but having to do this every time is stupid.

I looked into what it would take to have the output be ordered by the utility. Turns out, not a lot.

This is the entire patch.

Here is how to rebuild your apt with this patch. # means a root shell, % means an unprivileged user's shell.

Install dependencies as root, or use sudo:

# apt-get build-dep apt

Create a new directory and change to it, then get apt's source:

% apt-get source apt

Get and apply the patch:

% cd apt-*
% wget
% patch -p1 <apt-cache-sorted-output-patch.diff

Build the new apt:

% dpkg-buildpackage

The build will fail at the end with a failure to sign the package. Ignore the error and navigate up one level where you will find several .deb files. Install apt_.deb:

# dpkg -i apt_*.deb

Enjoy sorted output from apt-cache.