0
people have the following situation:
var input1 = {preco:valor1.toFixed(3), tipo:name1};
var input2 = {preco:valor2.toFixed(3), tipo:name2};
var input3 = {preco:valor3.toFixed(3), tipo:name3};
var input4 = {preco:valor4.toFixed(3), tipo:name4};
and I would like to display the values of these 4 arrays in ascending order of the 'price' as follows:
Lowest value: type: price Second lowest value: Tipo2: preco2 (...)
how can I sort the 4 arrays according to the value of one of the objects of each one of them?
EDIT to better illustrate:
var valor1 = 50;
var name1 = "nome1";
var valor2 = 20;
var name2 = "nome2";
var valor3 = 60;
var name3 = "nome3";
var valor4 = 10;
var name4 = "nome4";
var input1 = {preco:valor1.toFixed(3), tipo:name1};
var input2 = {preco:valor2.toFixed(3), tipo:name2};
var input3 = {preco:valor3.toFixed(3), tipo:name3};
var input4 = {preco:valor4.toFixed(3), tipo:name4};
and after ordering, in that case, should print
Lowest Value: nome4 - 10
Second Lowest Value: Nome2 - 20
Third Lowest Value: nome1 - 50
Quarto Menor Valor: nome3 - 60
I’m not seeing 4 arrays, I’m seeing 4 objects, what you want is that property
preco
ofinput1
receive the lowest value betweenvalor1
,valor2
,valor3
andvalor4
?– Tobias Mesquita
no... there are 4 products... in input1 it is storing the value and the name of the product1 as well as in the other...
– Heathz