MCPcopy Create free account
hub / github.com/geekcomputers/Python / insertion_sort_desc

Function insertion_sort_desc

insertion_sort.py:37–57  ·  view source on GitHub ↗

sort list in desending order INPUT: list=list of values to be sorted n=size of list that contains values to be sorted OUTPUT: list of sorted values in desending order

(list, n)

Source from the content-addressed store, hash-verified

35
36
37def insertion_sort_desc(list, n):
38 """
39 sort list in desending order
40
41 INPUT:
42 list=list of values to be sorted
43 n=size of list that contains values to be sorted
44
45 OUTPUT:
46 list of sorted values in desending order
47 """
48 for i in range(0, n):
49 key = list[i]
50 j = i - 1
51 # Swap elements witth key iff they are
52 # greater than key
53 while j >= 0 and list[j] < key:
54 list[j + 1] = list[j]
55 j = j - 1
56 list[j + 1] = key
57 return list
58
59
60input_list()

Callers 1

insertion_sort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected