Python Challenge - Top Score Sorter

def score_sorter(array, top_score):

Write your code here

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 :ok_hand:

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):

Write your code here

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):

Write your code here

f =
while len(array)>0:
for i in array:
if i == max(array):
f.append(max(array))
array.remove(i)
return f

score_list = [1, 2, 3,42,50,200, 9999, 13]
top = 10000

print(score_sorter(score_list, top))