The naming pattern for eastern European Ashkenazi Jews was:
1. A child is named for a deceased ancestor or a deceased highly
respected person, but never for a living person. Subject to that rule:
2. The first son is named for its father's father; the second son
for its mother's father.
3. The first daughter is named for its mother's mother; the second
daughter for its father's mother.
4. If someone cannot have a namesake in the normal order of rules
2 or 3 because they are still alive at the appropriate time, the next
baby of the appropriate sex to be born after the death of that person
will be named for that person.
5. When the child's father dies during the pregnancy, the child is
named after the child's father if the child is a boy.
After that, I do not think there was a rule.
One must remember that this is only a custom. Individuals could,
and sometimes did, disregard custom.