A project board lists tasks as objects { title, priority, due }. priority is "high", "medium", or "low", and due is a day number. The board shows high-priority tasks first, then medium, then low. Within a priority, earlier due days come first. If those match too, titles go in dictionary order by character codes.
Write sortBoard(tasks) that returns the task titles in board order. Do not change the input.
Input: tasks = [{"title":"Docs","priority":"low","due":1},{"title":"Login bug","priority":"high","due":5},{"title":"Navbar","priority":"high","due":2}] Output: ["Navbar","Login bug","Docs"]
Both high tasks come first, the one due on day 2 before day 5. The low task goes last even though it is due soonest.
Input: tasks = [{"title":"b","priority":"medium","due":3},{"title":"a","priority":"medium","due":3}] Output: ["a","b"]
Same priority and day, so the titles decide.
0 <= tasks.length <= 100000 <= due <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #221 Sort the Task Board. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.