Optimize expandable quicksort (speed and memory).

Previously, memory consumption grew quadratically in the
number of items.  Now sorting a list of several thousand
items should not be a big problem (somewhat slow).  The
code is unfortunately quite a bit longer, but hopefully
explained enough in comments.


git-svn-id: http://www.latex-project.org/svnroot/experimental/trunk@4489 de43f980-851b-0410-b2f7-c40aca1f87e0