Created
September 10, 2019 23:22
-
-
Save TechWithTy/ad31723fd74a50a08cd103cc210bb48d to your computer and use it in GitHub Desktop.
Sorting Algorithm One Liners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// console.log( | |
// tempProducts.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)), | |
// 'Price Lowest to Highest' | |
// ); | |
// console.log( | |
// tempProducts.sort((a, b) => parseFloat(b.price) - parseFloat(a.price)), | |
// 'Price Highest to Lowest' | |
// ); | |
// console.log( | |
// tempProducts.sort((a, b) => parseFloat(b.avgReview) - parseFloat(a.avgReview) ), | |
// | |
// ); Best Selling By Review | |
//Sort By Oldest | |
// console.log( | |
// tempProducts.sort((a, b) => new Date(a.uploadDate) - new Date(b.uploadDate))); | |
// Newest To Oldest | |
// Sort By Latest | |
console.log( | |
tempProducts.sort((a, b) => new Date(b.uploadDate) - new Date(a.uploadDate) )); | |
// Sort by Featured Bool | |
// console.log(tempProducts.sort((a, b) => b.isFeatured - a.isFeatured )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment