Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(info, sortingParam) {
- class Ticket {
- constructor(tokens) {
- this.destination = tokens[0];
- this.price = Number(tokens[1]);
- this.status = tokens[2];
- }
- }
- const tickets = [];
- for (const stuff of info) { tickets.push(new Ticket(stuff.split('|'))); }
- return tickets.sort(function (a, b) { if (sortingParam != 'price') { return a[sortingParam].localeCompare(b[sortingParam]); } else { return a.price - b.price; } });
- }
Advertisement
Add Comment
Please, Sign In to add comment