How to use fast-sort - 9 common examples

To help you get started, we’ve selected a few fast-sort 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 snovakovic / fast-sort / test / integration / index.js View on Github external
function run(err) {
  if (err) {
    console.error('Problem with installing fast-sort aborting execution', err);
    return;
  }

  const sortDefault = require('fast-sort');
  const sortEs6 = require('fast-sort/sort');
  const sortEs5 = require('fast-sort/sort.es5');
  const sortEs5Min = require('fast-sort/sort.es5.min');

  // sort
  assert.deepEqual(sortDefault([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs6([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs5([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs5Min([1, 4, 3]).asc(), [1, 3, 4]);
  console.log('sort: SUCCESS');
}
github snovakovic / fast-sort / test / integration / index.js View on Github external
function run(err) {
  if (err) {
    console.error('Problem with installing fast-sort aborting execution', err);
    return;
  }

  const sortDefault = require('fast-sort');
  const sortEs6 = require('fast-sort/sort');
  const sortEs5 = require('fast-sort/sort.es5');
  const sortEs5Min = require('fast-sort/sort.es5.min');

  // sort
  assert.deepEqual(sortDefault([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs6([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs5([1, 4, 3]).asc(), [1, 3, 4]);
  assert.deepEqual(sortEs5Min([1, 4, 3]).asc(), [1, 3, 4]);
  console.log('sort: SUCCESS');
}
github Datawheel / canon / packages / vizbuilder / src / helpers / fetch.js View on Github external
return api.query(mondrianQuery).then(result => {
    const dataset = (result.data || {}).data || [];

    if (dataset.length === 0) {
      throw new EmptyDataset();
    }

    sort(dataset).desc(measureName);
    const members = getIncludedMembers(query, dataset);

    let dataAmount = dataset.length;
    if (Array.isArray(members[timeLevelName])) {
      dataAmount *= 1 / members[timeLevelName].length;
    }
    if (dataAmount > datacap) {
      throw new TooMuchData(mondrianQuery, dataAmount);
    }

    return {dataset, members, query};
  });
}
github Datawheel / canon / packages / vizbuilder / src / helpers / sort.js View on Github external
export function sortKindaNumbers(list, desc = false) {
  return sort(list)[desc ? "desc" : "asc"](findFirstNumber);
}
github Datawheel / canon / packages / vizbuilder / src / helpers / sorting.js View on Github external
const measure = cube.measures[nMsr];
      const hideInMap = mapMode && yn(measure.annotations.hide_in_map);
      if (isValidMeasure(measure) && !hideInMap) {
        (cbHasTopic ? measures : otherMeasures).push(measure);
        if (cbTableId) {
          const key = `${cbTableId}.${measure.name}`;
          multiMeasures[key] = multiMeasures[key] || [];
          multiMeasures[key].push(measure);
        }
      }
    }
  }

  const sortingFunction = a => a.annotations._sortKey;
  const sortedMeasures = sort(measures).asc(sortingFunction);
  const sortedOther = sort(otherMeasures).asc(sortingFunction);

  return {
    measures: sortedMeasures.concat(sortedOther),
    measureMap: multiMeasures
  };
}
github Datawheel / canon / packages / vizbuilder / src / store / cubes / selectors.js View on Github external
let m = cube.measures.length;
      while (m--) {
        const measure = cube.measures[m];
        const {topic} = measure;
        const hideInMap = isGeomapMode && measure.hideInMap;

        if (isValidMeasure(measure) && !hideInMap) {
          const hasTopic = topic && topic !== "Other";
          (hasTopic ? topicMeasures : otherMeasures).push(measure);
        }
      }
    }

    return measures.concat(
      sort(topicMeasures).asc(measure => measure.sortKey),
      sort(otherMeasures).asc(measure => measure.sortKey)
    );
  }
);
github Datawheel / canon / packages / vizbuilder / src / helpers / fetch.js View on Github external
return api.query(mondrianQuery, "json").then(result => {
    const members = result.data.axes[1].members;
    sort(members).asc("full_name");
    return members;
  });
}
github Datawheel / canon / packages / vizbuilder / src / helpers / sort.js View on Github external
export function sortByProperty(list, property, desc = false) {
  return sort(list)[desc ? "desc" : "asc"](property);
}
github Datawheel / canon / packages / vizbuilder / src / helpers / sorting.js View on Github external
export function joinDrilldownList(array, drilldown) {
  array = array.filter(dd => dd.hierarchy !== drilldown.hierarchy);
  drilldown = [].concat(drilldown || []);
  drilldown = union(array, drilldown);
  return sort(drilldown).asc(a => a.hierarchy.dimension.dimensionType);
}

fast-sort

Fast easy to use and flexible sorting with TypeScript support

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis