Sort an Array Alphabetically using the sort Method


#1

Tell us what’s happening:

Your code so far


function alphabeticalOrder(arr) {
  // 请在本行以下添加你的代码
  return arr.sort(function(a,b) {
    return a > b;
  });
  
  // 请在本行以上添加你的代码
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.one/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method