Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Absolute Sorting by hamukazu
def checkio(numbers_array):
return tuple(sorted(numbers_array,key=abs))
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio((-20, -5, 10, 15)) == (-5, 10, 15, -20), "Example" # or [-5, 10, 15, -20]
assert checkio((1, 2, 3, 0)) == (0, 1, 2, 3), "Positive numbers"
assert checkio((-1, -2, -3, 0)) == (0, -1, -2, -3), "Negative numbers"
Feb. 20, 2014
Comments: