Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
SCIENTIFIC EXPEDITION - "Absolute Sorting" solution in Uncategorized category for Absolute Sorting by jsg-inet
def checkio(values: list) -> list:
# your code here
values_abs=[abs(x) for x in values]
values_abs_sorted=values_abs.copy()
values_abs_sorted.sort()
new_list=[]
for y in values_abs_sorted:
new_list.append(values[values_abs.index(y)])
return new_list
if __name__ == '__main__':
print("Example:")
print(checkio([-20, -5, 10, 15]))
# These "asserts" are used for self-checking and not for an auto-testing
assert checkio([-20, -5, 10, 15]) == [-5, 10, 15, -20]
assert checkio([1, 2, 3, 0]) == [0, 1, 2, 3]
assert checkio([-1, -2, -3, 0]) == [0, -1, -2, -3]
print("Coding complete? Click 'Check' to earn cool rewards!")
June 16, 2021
Comments: