Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function sortByAscendingDemo(orders) {
// Sorting works by comparing two values in a callback.
// When o1.quantity < 0, then o1 comes before o2.
// When o2.quantity < 0, then o2 comes before o1.
// When o1.quantity === o2.quantity then no change is needed
var oderedOrders = orders.sort((o1, o2) => o1.quantity - o2.quantity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment