Skip to main content
Module

x/xnd/symbols/sortBy.ts>default

JavaScript augmentations and supplements
Latest
variable default
import { default } from "https://deno.land/x/xnd@v3.0.2/symbols/sortBy.ts";

Sorts an array in-place using natural order of the values selected and returns the sorted array.

A selector can be a property key string | number | symbol or a function (value: T) => Comparable.

const persons = [ { name: "Eve" }, { name: "Adam" } ];

persons[sortBy]("name");
// => [ { name: "Adam" }, { name: "Eve" } ]

persons[sortBy](({ name }) => name.length);
// => [ { name: "Eve" }, { name: "Adam" } ]

type

symbol