mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
make positions for channels and roles nicer (#1211)
* make role calculated position nicer * make channels sortable in a nice way too * stupid git web rebase editor * Update Guild.js * Update Guild.js * Update Guild.js * Update Guild.js * Update RESTMethods.js
This commit is contained in:
@@ -369,6 +369,18 @@ class Collection extends Map {
|
||||
return testVal !== value || (testVal === undefined && !collection.has(key));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The sort() method sorts the elements of a collection in place and returns the collection.
|
||||
* The sort is not necessarily stable. The default sort order is according to string Unicode code points.
|
||||
* @param {Function} [compareFunction] 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.
|
||||
* @returns {Collection}
|
||||
*/
|
||||
sort(compareFunction = (x, y) => +(x > y) || +(x === y) - 1) {
|
||||
return new Collection(Array.from(this.entries()).sort((a, b) => compareFunction(a[1], b[1], a[0], b[0])));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Collection;
|
||||
|
||||
Reference in New Issue
Block a user