Closed RazvanBugoi closed 2 years ago
function order(words){
const arr = words.split(" ")
arr.sort(function(a,b) {
const numberA = Number(a.match(/\d/g)[0])
const numberB = Number(b.match(/\d/g)[0])
if (numberA < numberB) {
return - 1;
}
if (numberA > numberB) {
return 1;
}
return 0
})
return words ? arr.join(" ") : ""
}
https://www.codewars.com/kata/55c45be3b2079eccff00010f/train/javascript