MCPcopy Create free account
hub / github.com/breck7/scroll / selection_sort

Function selection_sort

external/.d3.js:2008–2025  ·  view source on GitHub ↗
(compare)

Source from the content-addressed store, hash-verified

2006}
2007
2008function selection_sort(compare) {
2009 if (!compare) compare = ascending$2;
2010
2011 function compareNode(a, b) {
2012 return a && b ? compare(a.__data__, b.__data__) : !a - !b;
2013 }
2014
2015 for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
2016 for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
2017 if (node = group[i]) {
2018 sortgroup[i] = node;
2019 }
2020 }
2021 sortgroup.sort(compareNode);
2022 }
2023
2024 return new Selection$1(sortgroups, this._parents).order();
2025}
2026
2027function ascending$2(a, b) {
2028 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;

Callers

nothing calls this directly

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected