The final procedure called from the FinalSteps procedure is the Assign procedure(see Figure CS21.19). The last step ot the aigonthm, this procedure completes the assignment of bays to each product type and creates the final layout. The procedure begins with the final layout's formatting. There is then a small section of code that is related to the resolve options, we will discuss this in more detail in the next section. The assignment loop then hegins. We loop through the sorted list of product types in descending order of their weight values found in the Sortltems procedure. We then assign hays to each product hy looping through the list of snrted hays until the area requirement for the product type has been met. To reflect that an assignment has been mace, we format the assignod bay with tho color of tho product typo. When tho assign mont is finishcd for thc product typo. wc also updatc our lcgcnd with tho product type's color and index.