return string with letter alphabetical order javascript code example

Example 1: javascript string array sort alphabetically

var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort((a, b) =>
   a.localeCompare(b)//using String.prototype.localCompare()
);

Example 2: javascript return string in alphabetical order

function alphabet_Soup(str) { 

    return str.split("").sort().join("");
         
}

console.log(alphabet_Soup("Python"));

console.log(alphabet_Soup("Exercises"));


//My Solution 

function alphaOrder(str) {
    return str.split("").sort().join("");
}

console.log(alphaOrder("webdev"))