last nameyeefirst nametomage lexicographical comparisons the insertionsort(method is similar to that in insertsort javabut it has been adapted to compare the lastname key values of records rather than the value of primitive type we use the compareto(method of the string class to perform the comparisons in the insertionsort(method here' the expression that uses ita[in- getlast(compareto(temp getlast() the compareto(method returns different integer values depending on the lexicographical (that isalphabeticalordering of the string for which it' invoked and the string passed to it as an argumentas shown in table table operation of the compareto(method compareto( equals return value < > for exampleif is "catand is "dog"the function will return number less than in the program this method is used to compare the last name of [in- with the last name of temp stability sometimes it matters what happens to data items that happen to have equal keys for exampleyou may have employee data arranged alphabetically by last names (that isthe last names were used as key values in the sort now you want to sort the data by zip codebut you want all the items with the same zip code to continue to be sorted by 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 there are three persons with the last name of smith initially the 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