Test Setup Failed
Push — master ( 33ee2d...dc0942 )
by Ken M.
45s
created

check_it()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
1
def checkio(numbers_array):
2
    return sorted(list(numbers_array), key=abs)
3
4
5
# These "asserts" using only for self-checking and not necessary for
6
# auto-testing
7
if __name__ == '__main__':  # pragma: no cover
8
    def check_it(array):
9
        if not isinstance(array, (list, tuple)):
10
            raise TypeError("The result should be a list or tuple.")
11
        return list(array)
12
13
    # or (-5, 10, 15, -20)
14
    assert check_it(checkio((-20, -5, 10, 15))) == [-5, 10, 15, -20], "Example"
15
    assert check_it(checkio((1, 2, 3, 0))) == [0, 1, 2, 3], "Positive numbers"
16
    assert check_it(
17
        checkio((-1, -2, -3, 0))) == [0, -1, -2, -3], "Negative numbers"
18