Author: Geoff Kuenning <geoff@cs.hmc.edu>
Description:
 ispell reorders words in personal dictionary without good reason.
 .
 The correct approach is to build the internal data structure with variant
 spellings stored in the same order as they appear in the personal dictionary.
 Fortunately, this is easy, though the patch is to a different file. This one
 has been tested (That's what I get for trying to rush out a fix before a
 meeting!).

diff -Naurp ispell.orig/makedent.c ispell/makedent.c
--- ispell.orig/makedent.c	1995-01-23 18:28:27.000000000 +0000
+++ ispell/makedent.c	2009-08-03 10:58:33.000000000 +0000
@@ -416,9 +416,10 @@ int combinecaps (hdrp, newp)
     if (retval == 0)
 	{
 	/*
-	** Couldn't combine the two entries.  Add a new variant.  For
-	** ease, we'll stick it right behind the header, rather than
-	** at the end of the list.
+	** Couldn't combine the two entries.  Add a new variant.  We
+	** stick it at the end of the variant list because it's
+	** important to maintain order; this causes the personal
+	** dictionary to have a stable ordering.
 	*/
 	forcevheader (hdrp, oldp, newp);
 	tdent = (struct dent *) mymalloc (sizeof (struct dent));
@@ -428,10 +429,13 @@ int combinecaps (hdrp, newp)
 	    return -1;
 	    }
 	*tdent = *newp;
-	tdent->next = hdrp->next;
-	hdrp->next = tdent;
-	tdent->flagfield |= (hdrp->flagfield & MOREVARIANTS);
-	hdrp->flagfield |= MOREVARIANTS;
+	for (oldp = hdrp;
+	  oldp->next != NULL  &&  oldp->flagfield & MOREVARIANTS;
+	  oldp = oldp->next)
+	    ;
+	tdent->next = oldp->next;
+	oldp->next = tdent;
+	oldp->flagfield |= MOREVARIANTS;
 	combineaffixes (hdrp, newp);
 	hdrp->flagfield |= (newp->flagfield & KEEP);
 	if (captype (newp->flagfield) == FOLLOWCASE)
