Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The same story again solution in Clear category for [old] Absolute Sorting by hanpari
"use strict";
function absoluteSorting(numbers){
return numbers.sort( (i,j) => Math.abs(i) - Math.abs(j) );
}
var assert = require('assert');
if (!global.is_checking) {
assert.deepEqual(absoluteSorting([-20, -5, 10, 15]), [-5, 10, 15, -20], "Example");
assert.deepEqual(absoluteSorting([1, 2, 3, 0]), [0, 1, 2, 3], "Positive numbers");
assert.deepEqual(absoluteSorting([-1, -2, -3, 0]), [0, -1, -2, -3], "Negative numbers");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Sept. 11, 2016