podium-sort

Sorts arrays putting the highest numbers in the middle

Usage no npm install needed!

<script type="module">
  import podiumSort from 'https://cdn.skypack.dev/podium-sort';
</script>

README

podium-sort

Sorts an array of numbers putting the highest numbers in the middle.

Build Status npm version npm version

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 }
]);