bubble sort the bubble sort is notoriously slowbut it' conceptually the simplest of the sorting algorithmsand for that reason is good beginning for our exploration of sorting techniques bubble-sorting the baseball players imagine that you're nearsighted (like computer programso that you can see only two of the baseball players at the same timeif they're next to each other and if you stand very close to them given this impedimenthow would you sort themlet' assume there are playersand the positions they're standing in are numbered from on the left to on the right the bubble sort routine works like this you start at the left end of the line and compare the two kids in positions and if the one on the left (in is talleryou swap them if the one on the right is talleryou don' do anything then you move over one position and compare the kids in positions and againif the one on the left is talleryou swap them this is shown in figure here are the rules you're following compare two players if the one on the left is tallerswap them move one position right you continue down the line this way until you reach the right end you have by no means finished sorting the kidsbut you do know that the tallest kid is on the right this must be truebecause as soon as you encounter the tallest kidyou'll end up swapping him every time you compare two kidsuntil eventually he (or shewill reach the right end of the line this is why it' called the bubble sortas the algorithm progressesthe biggest items "bubble upto the top end of the array figure shows the baseball players at the end of the first pass