Lets say, I have a collection or list of objects {A A B A B B C C C D D E E D F F F}

The list is populated at random. Now I want it to rearrange the list as follows

{A B C D E F A B C D E F A B C D F}

**One way** to do is create buckets for each element from the existing list, and then go over each bucket sequentially picking and adding the elements in expected list till all buckets last.