set07

Sort orders by date — divide and conquer

7 / 26
read the snippet · pick its Big-O
function sortOrders(orders) {
if (orders.length <= 1) return orders;
const mid = orders.length ;
const left = sortOrders(orders.slice(0, mid));
const right = sortOrders(orders.slice(mid));
return mergeByDate(left, right);
}