Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // another example: Object.keys(register).sort((a, b) => Object.keys(register[b]).length - Object.keys(register[a]).length ||
- // a.localeCompare(b));
- function solve(array) {
- array.sort((a, b) => {
- if(a.length > b.length) { // first criteria
- return 1;
- } else if(a.length === b.length) {
- return a.toLowerCase().localeCompare(b.toLowerCase()); // second criteria
- } else {
- return -1;
- }
- })
- return(array.join('\n'));
- }
- solve(['test',
- 'Deny',
- 'omen',
- 'Default']
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement