const prices = [400.50, 3000, 99.99, 35.99, 12.00, 9500]; // Sorting books by their rating: // use slice to copy the array const acscendingsOrders = prices.slice().sort((a, b) => a.toFixed(2) - b.toFixed(2)) const descendingOrders = prices.slice().sort((a, b) => b.toFixed(2) - a.toFixed(2))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter