Node.js sort() function Last Updated : 30 Mar, 2023 Comments Improve Suggest changes Like Article Like Report sort() is an array function from Node.js that is used to sort a given array. Syntax: array_name.sort() Parameter: This function does not take any parameter. Return type: The function returns the sorted array. The program below demonstrates the working of the function: Program 1: javascript function sortDemo() { arr.sort() console.log(arr); } const arr = [3, 1, 8, 5, 2, 1]; sortDemo(); Output: [ 1, 1, 2, 3, 5, 8 ] Program 2: javascript function sortDemo() { arr.sort() console.log(arr); } const arr = [-3, 1, 10, 12, 1]; sortDemo(); Output: [ -3, 1, 1, 10, 12 ] Comment More infoAdvertise with us Next Article Node.js sort() function T Twinkl Bajaj Follow Improve Article Tags : Web Technologies Node.js NodeJS-function Similar Reads p5.js sort() function The sort() function in p5.js is used to sort the array elements. If the array elements are strings then it sorts them alphabetically and if the array elements are integers then it sorts them in increasing order. Syntax: sort(Array, Count) Parameters: This function accepts two parameters as mentioned 3 min read Node.js lodash.sortBy() Function Lodash is a module in Node.js that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc. The Loadsh.sortBy() function is used to sort the array in ascending order. Syntax: sortBy(collection, [iteratees=[_.identity]]) Parameters: This parameter holds 1 min read D3.js pie.sort() Function The pie.sort() function in D3.js is used to sort the data objects based on different properties of data. The comparator function can be used to define the basis on which the sorting would be done. Syntax: pie.sort( compare ) Parameters: This function accepts a single parameter as mentioned above and 4 min read D3.js nest.sortKeys() Function D3.js is a library built with JavaScript and particularly used for data visualization. The nest.sortKeys() function is used to sort the keys in a particular order i.e. ascending or descending. Syntax: nest.sortkeys( comparatorFunction ) Parameters: This function accepts a single parameter comparator 2 min read Underscore.js _.sortBy Function Underscore.js _.sortBy() function is used to sort all the elements of the list in ascending order according to the function given to it as a parameter. Passing the array with a function that returns the number and will sort the array in ascending order and return an array. The array can be both nume 3 min read Like