sequence into its bucketwe can put the entries back into in sorted order by enumerating the contents of the buckets [ ] [ ], [ in order we describe the bucket-sort algorithm in code fragment code fragment bucket-sort it is easy to see that bucket-sort runs in ( ntime and uses ( nspace hencebucket-sort is efficient when the range of values for the keys is small compared to the sequence size nsay (nor (nlognstillits performance deteriorates as grows compared to an important property of the bucket-sort algorithm is that it works correctly even if there are many different elements with the same key indeedwe described it in way that anticipates such occurrences stable sorting when sortting key-value pairsan important issue is how equal keys are handled let (( , ),( - , - )be sequence of such entries we say that sorting algorithm is stable iffor any two entries ( , and ( , of ssuch that and ( , precedes ( , in before sorting (that isi )entry ( , also precedes entry ( , after sorting stability is important for sorting algorithm because applications may want to preserve the initial ordering of elements with the same key our informal description of bucket-sort in code fragment does not guarantee stability this is not inherent in the bucket-sort method itselfhoweverfor we can easily modify our description to make bucket-sort stablewhile still preserving its ( nrunning time indeedwe can obtain stable bucket-sort algorithm by always removing the first element from sequence and from the sequences [iduring the execution of the algorithm