devops-exercises/topics/python/solutions/sort_solution.md
Ayobami Alaran A 211c28c340
Added new python exercise with solution (#346)
* added new python exercise and solution

* add sort exercise and solutions

* changed heading1

* fixed header description
2023-02-03 11:42:59 +02:00

598 B

Sort Descending - Solution

  1. write a function that sorts the following list of list without using the sorted() and .sort() function in descending order

def sort_desc(mat: list) -> list:
    """ Sorts a list in descending order

    Args:
        mat (list): paresd list

    Returns:
        list: A new list
    """
    new_list = []
    while mat != []:
        maxx = max(mat)
        new_list.append(maxx)
        mat.remove(maxx)
    return new_list

print(sort_func(mat_list))