We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, nice solution, but you don't need to .slice() anything, .parseInt() anything, or iterate over every char in every string of the same length. JavaScript does it for you.
Here is my solution.
function bigSorting(unsorted) {
return unsorted.sort((a, b) => {
if (a.length !== b.length) {
return a.length - b.length;
} else {
if (a < b) {
return -1;
} else if (a == b) {
return 0;
} else {
return 1;
}
}
})
}
P.D. How do i change the syntax of my comment to javascript, or any lenguage?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
Hi, nice solution, but you don't need to .slice() anything, .parseInt() anything, or iterate over every char in every string of the same length. JavaScript does it for you.
Here is my solution.
P.D. How do i change the syntax of my comment to javascript, or any lenguage?