// A copy sorted by a comparator
eles.sort(sortFn: ( a: Collection<NodeData, EdgeData, Data>, b: Collection<NodeData, EdgeData, Data>, ) => number): Collection<NodeData, EdgeData, Data>A copy sorted by a comparator. Note that sort order is a property of the collection, not of drawing: draw order is structural and there is no z-index.
| Name | Description |
|---|---|
sortFn: ( a: Collection<NodeData, EdgeData, Data>, b: Collection<NodeData, EdgeData, Data>, ) => number |
|
Returns
Collection<NodeData, EdgeData, Data>a new, sorted collection
Example
const sorted = eles.sort((a, b) => a.id().localeCompare(b.id()));console.log(sorted.first().id()); // 'a'