जावास्क्रिप्ट कैसे ऑर्डर करने के लिए एक सरणी के द्वारा एकाधिक पैरामीटर
कोड उदाहरण
1
0
क्रमबद्ध वस्तुओं की सरणी द्वारा 2 कुंजी मान
homes.sort(
function(a, b) {
if (a.city === b.city) {
// Price is only important when cities are the same
return b.price - a.price;
}
return a.city > b.city ? 1 : -1;
});