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:
Gus Caplan
2017-04-01 01:28:54 -05:00
committed by Crawl
parent c4e5292516
commit a4e0af2e45
7 changed files with 142 additions and 54 deletions

View File

@@ -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;