Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Sorting an array of objects by property values

let persolize=[ { key: 'speakers', view: 10 }, { key: 'test', view: 5 } ]
  
persolize.sort((a,b) => a.view - b.view);

//If it only array and not an array object, use below statement
//persolize.sort((a,b) => a - b);
Source by www.javascriptkit.com #
 
PREVIOUS NEXT
Tagged: #Sorting #array #objects #property #values
ADD COMMENT
Topic
Name
1+9 =