How do I sort a concatenated array in Javascript?
Posted
by Mayur
on Stack Overflow
See other posts from Stack Overflow
or by Mayur
Published on 2010-06-13T10:36:35Z
Indexed on
2010/06/13
10:42 UTC
Read the original article
Hit count: 286
JavaScript
my code:
var company=new Array("Kestrel Moon:","BB:");
var basicPri=new Array(1165,1231);
for(var i=0;i<15;i++){
var companyTotal=company[i].concat(basicPri[…
document.write(""+companyTotal+"")
It shows on the screen:
Kestrel Moon: 1165
BB: 1231
I want to sort the array so that it goes ascending order of highest value of price so it should display it as:
BB: 1231
Kestrel Moon: 1165
A normal sort would not do it as it would sort the prices but the company names stay where they are, how do I sort both arrays so it would display what I want to display?
Thank You
© Stack Overflow or respective owner