How to use the d3-array.ascending function in d3-array

To help you get started, we’ve selected a few d3-array examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-array / d3-array-tests.ts View on Github external
mixedObjectDateBisectorObject = d3Array.bisector((el, x) =>
    el.date.valueOf() - x.valueOf());

// bisect left
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14));
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 3, 4);

// bisect right
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14));
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 3, 4);

// ascending() -----------------------------------------------------------------

num = d3Array.ascending(undefined, 20);
num = d3Array.ascending(10, 20);
num = d3Array.ascending('10', '20');
num = d3Array.ascending(new Date(2016, 6, 13), new Date(2016, 6, 14));

// descending() ----------------------------------------------------------------

num = d3Array.descending(undefined, 20);
num = d3Array.descending(10, 20);
num = d3Array.descending('10', '20');
num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14));

// -----------------------------------------------------------------------------
// Test Transforming  Arrays
// -----------------------------------------------------------------------------

// merge() ---------------------------------------------------------------------
github orbiting / styleguide / src / components / Chart / utils.js View on Github external
(a, b) =>
      ascending(accessor(a), accessor(b)) ||
      ascending(array.indexOf(a), array.indexOf(b)) // stable sort
  )
github react-tools / react-move / docs / src / routes / documentation / NodeGroup / Example1.js View on Github external
      (a, b) => ascending(a.letter, b.letter) :
      (a, b) => b.frequency - a.frequency,
github hpcc-systems / Visualization / packages / common / src / Utility.ts View on Github external
data.sort(function (l, r) {
            for (let i = 0; i < sortBy.length; ++i) {
                const lVal = l[sortBy[i].idx];
                const rVal = r[sortBy[i].idx];
                if (lVal !== rVal) {
                    return sortBy[i].reverse ? d3Descending(lVal, rVal) : d3Ascending(lVal, rVal);
                }
            }
            return 0;
        });
    }
github orbiting / republik-frontend / components / Pledge / Accordion.js View on Github external
({ key: a }, { key: b }) =>
          ascending(+(a !== group), +(b !== group)) ||
          ascending(
            groups.findIndex(d => d.key === a),
            groups.findIndex(d => d.key === b)
          )
      )
github orbiting / republik-frontend / components / Card / Group.js View on Github external
allCards.sort((a, b) => {
      const aSwipe = swipedMap.get(a.id)
      const bSwipe = swipedMap.get(b.id)
      return aSwipe && bSwipe
        ? ascending(allSwipes.indexOf(aSwipe), allSwipes.indexOf(bSwipe))
        : ascending(!aSwipe, !bSwipe) ||
            ascending(allCards.indexOf(a), allCards.indexOf(b))
    })
  }
github newamericafoundation / teddy / packages / timeline / src / Timeline / index.js View on Github external
      .sort((a, b) => ascending(a.date, b.date))
      .map((val, i) => ({ ...val, id: i }));
github orbiting / republik-frontend / components / CrowdfundingStatus / index.js View on Github external
      .sort((a, b) => ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]