podium-sort
v1.0.5
Published
Sorts arrays putting the highest numbers in the middle
Downloads
3
Readme
podium-sort
Sorts an array of numbers putting the highest numbers in the middle.
Installation
npm install --save podium-sort
Usage
const podiumSort = require("podium-sort");
const input = [1, 2, 3, 4, 5];
const output = podiumSort(input);
expect(output).toEqual([2, 4, 5, 3, 1]);
Providing a mapper:
const podiumSort = require("podium-sort");
const input = [
{ value: 1 },
{ value: 2 },
{ value: 3 },
{ value: 4 },
{ value: 5 }
];
const output = podiumSort(input, element => element.value);
expect(output).toEqual([
{ value: 2 },
{ value: 4 },
{ value: 5 },
{ value: 3 },
{ value: 1 }
]);