loading...

Answer: Ordenar una matriz de objetos por valores de propiedad

arielcalisaya profile image Ariel Calisaya ・1 min read

It's beautiful and genuine

Here's a more flexible version, which allows you to create reusable sort functions, and sort by any field.

const sort_by = (field, reverse, primer) => {

  const key = primer ?
    function(x) {
      return primer(x[field])
    } :
    function(x) {
      return x[field]
    };

  reverse = !reverse ?
…

Discussion

pic
Editor guide