I am attempting to create some sort of loop that will check for a high score value in an array, add it to the array if it is higher than some of the other values, and move all of the lower values down.
For example the array is called Integer highScoreArray[12, 9, 8, 7]
and has 4 values in it. I have another array that keeps the corresponding dates that the high scores were achieved called String highDateArray["12/5/11", "3/4/11", "4,4/12", "6/6/10"]
.
How would I go about adding a new value and corresponding date to the arrays? i.e. If the new value was "10" and date was "5/29/12"?
I don't want to use the sort command on highScoreArray[]
because then I will lose track of where the corresponding values where in the highDateArray[]
. I am hoping to sort the two arrays in two columns of text in two separate linear layouts afterwards, so trying to keep them separate, am I making this more difficult that it needs to be?
for (int i = 0; i < highScoreArray.length; i++)
{
if(newHighScore>=highScoreArray[i])
{
// DO SOMETHING
}
}