You could do a very simple bubble sort algorithm. It’s quite slow, but so long as you don’t have a million scores saved then it should be fine.
It’s very simple indeed. What you need to do is place the scores in an array. Then loop through the array starting at index 1 (where 0 is the starting index of the array). Then what you do is test to see if the current index is greater than the previous index, and if so, swap them, if not, leave them as they are.
if you made a swap, you need to set a flag, and test outside the loop whether that flag is set or not. If it is set, then repeat the process… until eventually the flag is no longer set, in which case you know that they are ordered… as no swaps occurred…
here is some pseudo code (it’s not python… but should be able to translate it easily)
scores(0) as integer
temp as integer
flag as boolean
i as integer
flag = false
do
{
flag = false
for i = 1 to UpperBoundary(scores) {
if (scores(i) > scores(i - 1)) {
temp = scores(i)
scores(i) = scores(i-1)
scores(i-1) = temp
flag = true
}
}
} loop until (flag = false)
if you’re not sure how to convert it to python, Pm me… and I’ll re-write it for you… but if you know python you shouldn’t have any issues here…
hope this makes sense…
Whipster