Answers for "resequency array by atributo"

0

resequency array by atributo

var items = [
  { name: 'Edward', value: 21 },
  { name: 'Sharpe', value: 37 },
  { name: 'And', value: 45 },
  { name: 'The', value: -12 },
  { name: 'Magnetic' },
  { name: 'Zeros', value: 37 }
];
items.sort(function (a, b) {
  if (a.name > b.name) {
    return 1;
  }
  if (a.name < b.name) {
    return -1;
  }
  // a must be equal to b
  return 0;
});
Posted by: Guest on January-19-2021

Code answers related to "resequency array by atributo"

Code answers related to "Javascript"

Browse Popular Code Answers by Language