numbers from to how would you sort thosethe answer is surprisingly simple we know that we have entries in the array and we know exactly which items should go there and in which order this is very unusual situation as far as general sorting is concernedyet this kind of thing often comes up in every-day life for examplewhen hotel needs to sort the room keys for its rooms rather than employing one of the comparison-based sorting algorithmsin this situation we can do something much simpler we can simply put the items directly in the appropriate placesusing an algorithm such as that as shown in figure create array of size for + [ [ ] [icopy array into array figure simply put the items in the right order using their values this algorithm uses second array to hold the resultswhich is clearly not very memory efficientbut it is possible to do without that one can use series of swaps within array to get the items in the right positions as shown in figure = = for ni+while [ ! swap [ [ ]and [ii= = figure swapping the items into the right order without using new array as far as time complexity is concernedit is obviously not appropriate here to count the number of comparisons insteadit is the number of swaps or copies that is important the algorithm of figure performs copies to fill array and then another to return the result to array aso the overall time complexity is (nthe time complexity of the algorithm of figure looks worse than it really is this algorithm performs at most swapssince one itemnamely [ [ ]is always swapped into its final position so at worstthis has time complexity (ntoo this example should make it clear that in particular situationssorting might be performed by much simpler (and quickermeans than the standard comparison sortsthough most realistic situations will not be quite as simple as the case here once againit is the responsibility of the program designer to take this possibility into account