Children – Set Order by Birth SortDate #child #family #sortdate #update

There have been recurring wishes expressed in the RootsMagic Forums for an enhancement to globally sort each family of children in the order they were born. For example, have a look at this thread, Sorting all children in the database by birth order. Expressed there are good reasons to be cautious about such an operation but, for some users, the possibility of adverse positioning of children without dates is outweighed by the time saved in organizing those who do. Until RootsMagic does offer such a feature, here is a script that sorts children by birth date.

While executing the script is straightforward, the underlying procedures involve several temporary SQlite Views and a temporary Table. It tries to pick out the dominant event for a person from his/her collection of Primary and non-Primary Birth and Christening events. A single Primary Birth with date is handled best; multiple Primaries or multiple events of the same type in the absence of a Primary may give an undesired order if dates overlap with another child.

The script only updates the child-sorting value (ChildTable.ChildOrder) of those children with a birth-type event having a SortDate and only for those families in which all children have said SortDate. The ChildOrder value of other families is left unchanged. Thus, it should be safe to use this script on a database for which some families have children lacking a birth-type fact or a SortDate for same; it will not affect the order of children whether they are still in the sequence they were added to the family or were subsequently manually rearranged.

To find families which still need to be rearranged manually after having run this script, see Children – Needing Manual Arranging.

It is the SortDate of the birth-type event which is the sorting key, not the Date. This means that users can enter a Birth fact without a Date or with a text Date (unrecognised date format) but with a SortDate estimated to be appropriate and what they might have in mind were they manually rearranging the children. The child order would then be reconstructed correctly by the script.

Almost any SQLite3 manager should be capable of executing this script. As usual, make a backup or work on a copy of your database file so you can get back to where you were before the script executes if you don’t like the outcome.

Children-SetOrderByBirthSortDate.sql
2015-01-22 1st release
2015-01-22 rev to preserve the order of children in families where 1 or more have no birth sortdate or no birth fact.
2015-01-24 rev to correct the override of valid Christen SortDates by empty Birth SortDates

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.