on the other handfor larger collectionswe want to take advantage of as many improvements as possible in this section we will discuss several sorting techniques and compare them with respect to their running time before getting into specific algorithmswe should think about the operations that can be used to analyze sorting process firstit will be necessary to compare two values to see which is smaller (or largerin order to sort collectionit will be necessary to have some systematic way to compare values to see if they are out of order the total number of comparisons will be the most common way to measure sort procedure secondwhen values are not in the correct position with respect to one anotherit may be necessary to exchange them this exchange is costly operation and the total number of exchanges will also be important for evaluating the overall efficiency of the algorithm bubble sort the bubble sort makes multiple passes through list it compares adjacent items and exchanges those that are out of order each pass through the list places the next largest value in its proper place in essenceeach item "bubblesup to the location where it belongs figure shows the first pass of bubble sort the shaded items are being compared to see if they are out of order if there are items in the listthen there are pairs of items that need to be compared on the first pass it is important to note that once the largest value in the list is part of pairit will continually be moved along until the pass is complete at the start of the second passthe largest value is now in place there are items left to sortmeaning that there will be pairs since each pass places the next largest value in placethe total number of passes necessary will be after completing the passesthe smallest item must be in the correct position with no further processing required the code below shows the complete bubble_sort function it takes the list as parameterand modifies it by exchanging items as necessary def bubble_sort(a_list)for pass_num in range(len(a_list - )for in range(pass_num)if a_list[ia_list[ ]temp a_list[ia_list[ia_list[ a_list[ temp a_list [ bubble_sort(a_listprint(a_listthe exchange operationsometimes called "swap,is slightly different in python than in most other programming languages typicallyswapping two elements in list requires temporary storage location (an additional memory locationa code fragment such as temp a_list[ia_list[ia_list[ sorting and searching