Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let sorted = input.sort(sortedNames);
- console.log(sorted.join('\n'));
- function sortedNames(a, b) {
- let firstCriteria = a.length - b.length;
- if (firstCriteria === 0) {
- return a.localeCompare(b);
- }
- return firstCriteria;
- }
- }
- /*Write a function that orders an array of strings, by their length in ascending order as primary criteria, and by alphabetical value in ascending order as second criteria. The comparison should be case-insensitive.*/
Advertisement
Add Comment
Please, Sign In to add comment