<commit_before>import "../core/functor";
import "geom";
import "point";

/**
 * Computes the 2D convex hull of a set of points using the monotone chain
 * algorithm:
 * http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain)
 *
 * The runtime of this algorithm is O(n log n), where n is the number of input
 * points. However in practice it outperforms other O(n log n) hulls.
 *
 * @param vertices [[x1, y1], [x2, y2], …]
 * @returns polygon [[x1, y1], [x2, y2], …]
 */
d3.geom.hull = function(vertices) {
  var x = d3_geom_pointX,
      y = d3_geom_pointY;

  if (arguments.length) return hull(vertices);

  function hull(data) {
    // Hull of < 3 points is not well-defined
    if (data.length < 3) return [];

    var fx = d3_functor(x),
        fy = d3_functor(y),
        n = data.length;

    for (i = 0, points = []; i < n; ++i) {
      points.push([+fx.call(this, d = data[i], i), +fy.call(this, d, i), i]);
    }

    // sort ascending by x-coord first, y-coord second
    points.sort(function(a, b) {
      return (a[0] < b[0] || (a[0] === b[0] && a[1] < b[1])) ? -1 : 1;
    });

    // we flip bottommost points across y axis so we can use the upper hull  routine on both
    var flipped_points = [];<commit_msg>Clean up sort comparator<commit_after>import "../core/functor";
import "geom";
import "point";

/**
 * Computes the 2D convex hull of a set of points using the monotone chain
 * algorithm:
 * http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain)
 *
 * The runtime of this algorithm is O(n log n), where n is the number of input
 * points. However in practice it outperforms other O(n log n) hulls.
 *
 * @param vertices [[x1, y1], [x2, y2], …]
 * @returns polygon [[x1, y1], [x2, y2], …]
 */
d3.geom.hull = function(vertices) {
  var x = d3_geom_pointX,
      y = d3_geom_pointY;

  if (arguments.length) return hull(vertices);

  function hull(data) {
    // Hull of < 3 points is not well-defined
    if (data.length < 3) return [];

    var fx = d3_functor(x),
        fy = d3_functor(y),
        n = data.length;

    for (i = 0, points = []; i < n; i++) {
      points.push([+fx.call(this, d = data[i], i), +fy.call(this, d, i), i]);
    }

    // sort ascending by x-coord first, y-coord second
    points.sort(function(a, b) { return (a[0] - b[0]|| a[1] - b[1]); });

    // we flip bottommost points across y axis so we can use the upper hull routine on both
    var flipped_points = [];
{'fraction_non_alphanumeric': 0.15483353389490573, 'fraction_numerical': 0.018451664661050943, 'mean_word_length': 2.9650238473767887, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3169553', 'n_tokens_mistral': 941, 'n_tokens_neox': 891, 'n_words': 291}