Organize object array according to one of its attributes

Asked

Viewed 777 times

0

Well, it’s like the title said, I wonder if there’s any way I could arrange a array of objects of increasing shape according to the value of an attribute given to it.

Example:

var objetos = []

var objeto1 {id:gerarId(), nome: nome1, idade: idade1}

var objeto2 {id:gerarId(), nome: nome2, idade: idade2}

objetos.push(objeto1);

objetos.push(objeto2);

And like now I wanted to organize it in ascending order according to the value of age.

Detail: I’m using the localstorage to store the data, and I want to do everything in javascript.

  • I think what you want is this https://answall.com/questions/100068/order-um-array-de-objects-por-data/100076#100076

1 answer

2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.