Tabnine Logo For Javascript
Array.sort
Code IndexAdd Tabnine to your IDE (free)

How to use
sort
function
in
Array

Best JavaScript code snippets using builtins.Array.sort(Showing top 15 results out of 13,014)

origin: Automattic/wp-calypso

//sort by imported name
  importNames.sort( ( a, b ) => {
    if ( a.imported < b.imported ) {
      return -1;
    }
    if ( a.imported > b.imported ) {
      return 1;
    }
    return 0;
  } );
origin: axa-group/nlp.js

classify(terms) {
  const tfidfs = this.tfidfs(terms);
  const result = [];
  Object.keys(tfidfs).forEach((key) => {
   result.push({ document: key, score: tfidfs[key] });
  });
  return result.sort((a, b) => b.score - a.score);
 }
origin: strapi/strapi

[associationA, associationB]
   .sort((a, b) => {
    if (a.collection === b.collection) {
     if (a.dominant) return 1;
     else return -1;
    }
    return a.collection < b.collection ? -1 : 1;
   })
   .map(table =>
    _.snakeCase(`${pluralize.plural(table.collection)} ${pluralize.plural(table.via)}`)
   )
   .join('__')
origin: tulios/kafkajs

it('updates the list of brokers', async () => {
   expect(brokerPool.brokers).toEqual({})
   await brokerPool.refreshMetadata([topicName])
   expect(Object.keys(brokerPool.brokers).sort()).toEqual(['0', '1', '2'])
   expect(Object.values(brokerPool.brokers)).toEqual(
    expect.arrayContaining([expect.any(Broker), expect.any(Broker), expect.any(Broker)])
   )
  })
origin: axa-group/nlp.js

async run() {
  const result = [];
  for (let i = 0; i < this.algorithms.length; i += 1) {
   const value = await this.measure(this.algorithms[i]);
   result.push(value);
  }
  return result.sort(
   (a, b) => b.transactionsPerSecond - a.transactionsPerSecond
  );
 }
origin: microsoft/botframework-sdk

const cleanupEntities = function(luisObject) {
  let consolidatedList = [];
  luisObject.composites.forEach(item => consolidatedList.push(item));
  luisObject.closedLists.forEach(item => consolidatedList.push(item));
  luisObject.regex_entities.forEach(item => consolidatedList.push(item));
  luisObject.prebuiltEntities.forEach(item => consolidatedList.push(item));
  let idxToRemove = [];
  luisObject.entities.forEach((item, idx) => {
    if (consolidatedList.find(e => e.name == item.name) !== undefined) idxToRemove.push(idx);
  })
  idxToRemove.sort((a, b) => a-b).forEach(idx => luisObject.entities.splice(idx, 1))
}
origin: tulios/kafkajs

const decode = async rawData => {
 const decoder = new Decoder(rawData)
 return {
  topicErrors: decoder.readArray(topicErrors).sort(topicNameComparator),
 }
}
origin: GitSquared/edex-ui

var projectGraph = function ( root, sortObjects ) {

    _objectCount = 0;

    _renderData.objects.length = 0;
    _renderData.lights.length = 0;

    projectObject( root );

    if ( sortObjects === true ) {

      _renderData.objects.sort( painterSort );

    }

  }
origin: tulios/kafkajs

generatePartitionsPerSubscribedTopic() {
  const map = new Map()

  for (const topic of this.topicsSubscribed) {
   const partitions = this.cluster
    .findTopicPartitionMetadata(topic)
    .map(m => m.partitionId)
    .sort()

   map.set(topic, partitions)
  }

  return map
 }
origin: GoogleChromeLabs/ndb

function stringify(value) {
 function stabilize(key, object) {
  if (typeof object !== 'object' || object === undefined || object === null)
   return object;
  const result = {};
  for (const key of Object.keys(object).sort())
   result[key] = object[key];
  return result;
 }

 return JSON.stringify(stabilize(null, value), stabilize);
}
origin: axa-group/nlp.js

vectorToClassifications(vector) {
  const obj = this.outputLookup.vectorToObj(vector);
  const result = [];
  Object.keys(obj).forEach((key) => {
   result.push({ intent: key, score: obj[key] });
  });
  return result.sort((a, b) => b.score - a.score);
 }
origin: Automattic/wp-calypso

function getValidCodemodNames() {
  return [ ...getLocalCodemodFileNames(), ...Object.getOwnPropertyNames( config.codemodArgs ) ]
    .map( ( name ) => '- ' + name )
    .sort();
}
origin: microsoft/botframework-sdk

private sortProperty(arrayToSort: any[], propertyToSort: string) {
  (arrayToSort || []).sort((a: any, b: any) => {
   const aValue = a[propertyToSort].toLowerCase()
   const bValue = b[propertyToSort].toLowerCase()

   return aValue < bValue ? -1 : aValue > bValue ? 1 : 0
  })
 }
origin: parse-community/parse-server

Object.keys(oauth_parameters)
  .sort()
  .map(function(key) {
   var value = oauth_parameters[key];
   return key + '="' + value + '"';
  })
  .join(', ')
origin: Automattic/wp-calypso

//sort by imported name
  importNames.sort( ( a, b ) => {
    if ( a.imported < b.imported ) {
      return -1;
    }
    if ( a.imported > b.imported ) {
      return 1;
    }
    return 0;
  } );
builtins(MDN)Arraysort

JSDoc

Sorts an array.

Most used builtins functions

  • Console.log
  • Console.error
  • Promise.then
    Attaches callbacks for the resolution and/or rejection of the Promise.
  • Promise.catch
    Attaches a callback for only the rejection of the Promise.
  • Array.push
    Appends new elements to an array, and returns the new length of the array.
  • Array.length,
  • Array.map,
  • String.indexOf,
  • fetch,
  • Window.location,
  • Window.addEventListener,
  • ObjectConstructor.keys,
  • Array.forEach,
  • Location.reload,
  • Response.status,
  • Navigator.serviceWorker,
  • ServiceWorkerContainer.register,
  • ServiceWorkerRegistration.installing,
  • ServiceWorkerContainer.controller

Popular in JavaScript

  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • winston
    A logger for just about everything.
  • async
    Higher-order functions and common patterns for asynchronous code
  • request
    Simplified HTTP request client.
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • mongodb
    The official MongoDB driver for Node.js
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now