prices= [500, 300, 400, 700];
names = ['product1', 'product2', 'product3', 'product4'];
binding={}
for (i in prices){
if(prices.hasOwnProperty(i))
binding[prices[i]]=names[i]
}
delete i
binding=[].sort.apply(binding)
prices=[]
names=[]
for(i in binding){
if(binding.hasOwnProperty(i)){
prices.push(i)
names.push(binding[i])
}
}
delete i
names=names.reverse()
prices=prices.reverse()
alert([prices, names])