advanced programming techniques the code begins by creating three constants that are used to provide names for index positions used by the local functions then we define the two local functions which we will review in moment the sorting algorithm works in two stages in the first stage we create list of entrieseach -tuple consisting of "keythat will be used for sortingthe original stringand list of the string' child entries the key is just lowercased copy of the string with whitespace stripped from both ends the level is the indentation level for top-level items for children of top-level itemsand so on in the second stage we create new indented list and add each string from the sorted entries listand each string' child stringsand so onto produce sorted indented list def add_entry(levelkeyitemchildren)if level = children append((keyitem[])elseadd_entry(level keyitemchildren[- ][children]this function is called for each string in the list the children argument is the list to which new entries must be added when called from the outer function (indented_list_sort())this is the entries list this has the effect of turning list of strings into list of entrieseach of which has top-level (unindentedstring and (possibly emptylist of child entries if the level is (top-level)we add new -tuple to the entries list this holds the key (for sorting)the original item (which will go into the resultant sorted list)and an empty children list this is the base case since no recursion takes place if the level is greater than the item is child (or descendantof the last item in the children list in this case we recursively call add_entry(againreducing the level by and passing the children list' last item' children list as the list to add to if the level is or moremore recursive calls will take placeuntil eventually the level is and the children list is the right one for the entry to be added to for examplewhen the "inner transitionalsstring is reachedthe outer function calls add_entry(with level of key of "inner transitionals"an item of "inner transitionals"and the entries list as the children list since the level is new item will be appended to the children list (entries)with the keyitemand an empty children list the next string is lanthanides"--this is indentedso it is child of the "inner transitionalsstring the add_entry(call this time has level of key of "lanthanides"an item of lanthanides"and the entries list as the children list since the level is the add_entry(function calls itself recursivelythis time with level ( )the same key and itembut with the children list being the children list of the last itemthat isthe "inner transitionalsitem' children list here is what the entries list looks like once all the strings have been addedbut before the sorting has been done