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#sort

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

The sort method sorts the items of a collection in place 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.sort((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.