• Mission Idea: Sort a list by custom number

 

In this mission, the users have to sort a list of numbers e.g. [3,7,2,5,8,9,4,1,3] so that the first element of the list is a given element and the order of each element within each other do not change.

def custom_sort(items: list, start: int) -> list

assert list(custom_sort([3,7,2,5,8,9,4,1,3], 5)) == [5,8,9,4,1,3,3,7,2]

In this example 5 was the element number 3 before and after the function it became the first and the order of each element within each other is not changed. If there are more int with the same value in the list, the program should consider the one that appear first in the list.

Another example: assert list(customsort([1,2,3,4,5], 2)) == [2,3,4,5,1] assert list(customsort([6,3,5,7,3,2,6,7,3,5,6,8,11,0], 7)) == [7,3,2,6,7,3,5,6,8,11,0,6,3,5]