kazali,
var prices = [500, 300, 400, 700],
names = ['product1', 'product2', 'product3', 'product4'],
temp = {};
for (var i = 0; i < names.length; i++) {
temp[names[i]] = prices[i]
};
names.sort(function(a, b) {
return temp[b] - temp[a]
});
prices.sort(function(a, b) {
return b - a
});
alert(prices + '\n' + names)