Arrays.sort() issue when Numbers are a string!
807606Mar 7 2007 — edited Mar 7 2007Hey guys -- here is my problem.
I am working on a TOP TEN SCORES mechanism for a trivia game. I have read in the score and the players name from a file. SO I have 2 different arrays topScores[] and topNames[] ---
Now if someone plays the game and has a higher score than the lowest score, they get to put their score and name in the file and replace the low score.
HOWEVER -- I do not know how to sort topSCORES[] and then make whatever sorted changes apply also to the topNAMES[] array.
SO I thought - HEY I will concatenate the topScores and topNames into a single String array. And then SORT! This sounded like a great idea until I realized that the following will happen:
100 tvance (first one)
1000 dvance (second score)
250 danderson (third score) !!!
See my problem? When I sort this way - it is sorting alphabetically so it will put a 1000 score before a 200-900 score! ---
**I hope I explained this adequately -- can someone help? Is there a way to sort the topScores array and have it also change the order of the topNames array as well?