MCPcopy Index your code
hub / github.com/simple-statistics/simple-statistics / numericSort

Function numericSort

src/numeric_sort.js:18–28  ·  view source on GitHub ↗

* Sort an array of numbers by their numeric value, ensuring that the * array is not changed in place. * * This is necessary because the default behavior of .sort * in JavaScript is to sort arrays as string values * * [1, 10, 12, 102, 20].sort() * // output * [1, 10, 102, 12, 20]

(x)

Source from the content-addressed store, hash-verified

16 * numericSort([3, 2, 1]) // => [1, 2, 3]
17 */
18function numericSort(x) {
19 return (
20 x
21 // ensure the array is not changed in-place
22 .slice()
23 // comparator function that treats input as numeric
24 .sort(function (a, b) {
25 return a - b;
26 })
27 );
28}
29
30export default numericSort;

Callers 4

modeFunction · 0.85
ckmeansFunction · 0.85
quantileRankFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected