Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let output = [];
- for (element of input) {
- let name = element.split(`,`)[0];
- if (!output.includes(element)) {
- output.push(name);
- }
- output
- .sort((a, b) => {
- let result =a.length - b.length;
- if (result === 0) {
- result = a.localeCompare(b);
- }
- return result;
- });
- }
- console.log(output.join(`\n`));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement