The important thing to remember here is that the “sorted list of tables” will change depending on whether you are either Inserting or Deleting data.
I like the image used by w3resource – to depict a Foreign Key.
In simple terms,
SQL Foreign Key. A foreign key is a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.
In any case, the attached PROC provides a list of “ordered tables based on the tables’ Foreign key.”
Let me know if you have any questions,