Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/revoltio/src/util/mod.ts>Collection#sorted

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.sorted
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/src/util/mod.ts";

The sorted method sorts the items of a collection and returns it. The sort is not necessarily stable in Node 10 or older. The default sort order is according to string Unicode code points.

Examples

collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);

Parameters

optional
compareFunction: Comparator<K, V>

Specifies a function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.