Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

lodash sort json

// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var object = [
  { 'obj': 'moto', 'price': 19999 },
  { 'obj': 'oppo', 'price': 18999 },
  { 'obj': 'moto', 'price': 17999 },
  { 'obj': 'oppo', 'price': 15999 } ];
   
// Use of _.sortBy() method
let gfg = _.sortBy(object, ['obj', 'price']);
  
// Printing the output 
console.log(gfg);
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #lodash #sort #json
ADD COMMENT
Topic
Name
7+1 =