Testing the “Ordering by surnames within families”, I noticed a peculiarity when using a particular GEDCOM file. When a particular family was ordered by ancestor it used 2 starting ancestors, but when ordered by surname it used 3 and they were not the same. This seemed very strange. After some debugging, I found the ordering routine I just created had no problems. The problem stemmed from the code I had written very long ago to determine the ancestors. It seems that I didn’t eliminate the same couple occurring more than once during the determination process, but only prevented displaying them if they were already displayed. Because these couple were listed more than once and sometimes in husband/wife order and other times in wife/husband order, when ordering by surname, different couples could be chosen first than when ordering by ancestor.
Taking time to think about this, it seems that in Ancestor order you do not want to list the family twice since one occurrence will occur right after the other. But in surname order, you may want them both listed since their surnames will be different. The second one can of course cross reference back to the first one for the detailed info, but should still be listed.
Actually, there was also something I missed that sometimes caused the tree to explode, but I never noticed because the duplicate branches were never displayed. When searching all the husband’s wives and then all the wive’s husbands to obtain ancestors, I never eliminated the original husband and wife from the search, so each branch was searched upwards multiple times. This is now fixed.