The Numbering by Surname is somewhat more complicated. There are several ways to go about this, but I think the best might be to take advantage of the Name Index that has already been generated. The difficulty is to still filter the GEDCOMs and Families depending on what is selected for them in the Organize pages. What might be best here is to generate the ancestor list using the Family method but do not build the descendants yet. Then use the Name Index to create a sorted version of the ancestor list that will replace the Family-ordered list. This way, no extra code needs to be written and the Family filtering will still take place.