This is the instruction in one of the exercises in our Java class. Before anything else, I would like to say that I \'do my homework\' and I\'m not just being lazy asking someon
You can find so many different sorting algorithms in internet, but if you want to fix your own solution you can do following changes in your code:
Instead of:
orderedNums[greater]=tenNums[indexL];
you need to do this:
while (orderedNums[greater] == tenNums[indexL]) {
greater++;
}
orderedNums[greater] = tenNums[indexL];
This code basically checks if that particular index is occupied by a similar number, then it will try to find next free index.
Note: Since the default value in your sorted array elements is 0, you need to make sure 0 is not in your list. otherwise you need
to initiate your sorted array with an especial number that you sure is
not in your list e.g: Integer.MAX_VALUE