Skip to content

sort

Sort an array without modifying it and return the newly sorted value.

Usage

const fish = [
{ name: "Marlin", weight: 105 },
{ name: "Bass", weight: 8 },
{ name: "Trout", weight: 13 },
];
sort(fish, (f) => f.weight); // => [Bass, Trout, Marlin]
sort(fish, (f) => f.weight, true); // => [Marlin, Trout, Bass]

Installation

Terminal window
npx atmx add helper sort