Given the task to sort the numbers in the list without the built-in functions sort , max and sorted . And you need to use the function given below. I tried to do it in this way, but failed:

def max_num(num): j = 0 for i in num: if j < i: j = i return j def min_num(num): h = 1 for i in num: if h > i: h = i return h lst = [2,235,654,4346,754,32,1] k = max_num(lst) g = min_num(lst) spisok = lst[g:k] print(spisok) print(g, k) 

    1 answer 1

    1 - there is still no such sorting algorithm that would be written without cycles
    2 - the functions of the minimum and maximum return the values ​​of the array and not the indices to which you then refer
    You need to use sorting by the minimum (when the minimum element is taken and inserted into the beginning of the list) and so for all n numbers. There is a lot of information on this type of sorting, it is unlikely to help here better than the finished article and code that are easy to find.

    • Thank you, I will try to find something ) - Sofanchik