simple sorting last names you want the algorithm to sort only what needs to be sortedand leave everything else in its original order some sorting algorithms retain this secondary orderingthey're said to be stable all the algorithms in this are stable for examplenotice the output of the objectsort java program (listing three persons have the last name of smith initiallythe order is doc smithlorraine smithand paul smith after the sortthis ordering is preserveddespite the fact that the various smith objects have been moved to new locations comparing the simple sorts there' probably no point in using the bubble sortunless you don' have your algorithm book handy the bubble sort is so simple that you can write it from memory even soit' practical only if the amount of data is small (for discussion of what "smallmeanssee "when to use what "the selection sort minimizes the number of swapsbut the number of comparisons is still high this sort might be useful when the amount of data is small and swapping data items is very time-consuming compared with comparing them the insertion sort is the most versatile of the three and is the best bet in most situationsassuming the amount of data is small or the data is almost sorted for larger amounts of dataquicksort is generally considered the fastest approachwe'll examine quicksort in we've compared the sorting algorithms in terms of speed another consideration for any algorithm is how much memory space it needs all three of the algorithms in this carry out their sort in placemeaning thatbesides the initial arrayvery little extra memory is required all the sorts require an extra variable to store an item temporarily while it' being swapped you can recompile the example programssuch as bubblesort javato sort larger amounts of data by timing them for larger sortsyou can get an idea of the differences between them and the time required to sort different amounts of data on your particular system summary the sorting algorithms in this all assume an array as data storage structure sorting involves comparing the keys of data items in the array and moving the items (actuallyreferences to the itemsaround until they're in sorted order