Показать сообщение отдельно
  #3 (permalink)  
Старый 15.11.2014, 10:08
Профессор
Посмотреть профиль Найти все сообщения от krutoy
 
Регистрация: 09.11.2014
Сообщений: 610

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])
Ответить с цитированием