I'm creating a simple game in ruby, and I have two arrays storing high score: $HS_Points and $HS_Names. I'm saving high score in two files, and I wanted to encode points a bit (the points are converted with .to_s(23)). I wanted to sort names and scores in descending order and limit them to 10. So, I need to:
- Check whether amount of points player scored is higher than amounts of points in high score (on index 0 to 9).
- If the score received is enough to set player on top 10, put the points and name on that place, pushing other down by one place.
Simple points_array.sort won't do, because it will just sort the points, leaving the names in order they were.
Any ideas how to solve that problem? I'd please to keep answer as simple as possible.