rank[1] = rank[2]
rank[2] = rank[3]
rank[3] = rank[4]
rank[4] = rank[5]
rank[5] = rank[6]
rank[1] = 55
rank[2] = 75
rank[3] = 80
rank[4] = 85
rank[5] = x
Yep. That's it. You see now that all the scores are moved UP. And you wanted to move them down to make place on spot 1.
rank[1] = score(new value)
rank[2] = rank[1]
rank[3] = rank[2]
rank[4] = rank[3]
rank[5] = rank[4]
should it be like that?
Almost !!!. But again... lets draw it out.
You have 43, 55, 75, 80 and 85
What happens if you do the first line?
You get (new), 55, 75, 80 and 85
Where is value 43 gone?
And if you take rank[2]=rank[3] and the rest of the lines... what happens if you draw it out each line by line.
rank[2] = rank[3] will give you
(new), 75, 75, 80 and 85
Do you see what's going wrong.
If you don't see it yet... let's do it another way. Write down 33, 43, 55, 75, 80 and 85 on a small piece of paper.
Put 43 to 85 on the table above each other (like in the drawing).
Now remove 85 from it's spot (it's a score which will be discarded because it's too high).
Now, how (
AND IN WHAT ORDER) would you
move the numbers from spot to spot so that you get the following order: 33(new), 43, 55, 75 and 80.
(Please really do it with those pieces of paper. It will become really clear.)
(PS. I do this with you very slow. Because this is some vital understanding of arrays and you need to learn and try this a few times yourself. It will "burn" in your memory and in a few month you look upon this moment and say... yeah, that's when I got it)