Python Challenge - Top Score Sorter

def score_sorter(array, top_score):

array.sort()
if array[-1] <= top_score:
array.reverse()
return array
else:
return “Score was higher than top possible score”
score_list = [1, 2, 3, 9999, 13]
top = 10000

print(score_sorter(score_list, top))

I have chosen to work on the array passed as argument instead of creating another one

def score_sorter(array, top_score): for i in range(0, len(array)-1): for k in range(0, len(array)-1): if array[k] < array[i+1]: aux = array[i+1] array[i+1] = array[k] array[k] = aux """ Short way by using predefined methods: array.sort(reverse=True) return array """ return array score_list = [1, 2, 3, 9999, 13] top = 10000 print(score_sorter(score_list, top))

Hi everyone.

This was my solution to this challange:

def score_sorter(array, top_score): sorted_list = sorted(array, reverse=True) return sorted_list # Write your code here score_list = [1, 2, 3, 9999, 13] top = 10000 print(score_sorter(score_list, top))

man, you have to come up with your own algorithm, and not use ready-made built-in language functions

def score_sorter(array, top_score):

score_sort =
scores = array
while len(scores) > 0:
score_sort.append(max(scores))
index = scores.index(max(scores))
scores.pop(index)
#print(score_sort)
while max(score_sort) > top_score:
del score_sort[0]
return score_sort
score_list = [1, 2, 3, 9999, 13]
top = 10000

print(score_sorter(score_list, top))

def score_sorter(array, top_score):