TRIED EVERY DEBUGGING I KNEW : Sort an Array Alphabetically using the sort Method

Tell us what’s happening:

Your code so far


function alphabeticalOrder(arr) {
  // Add your code below this line
  return arr.sort(function(a,b) {
    return a > b;
  });
  // Add your code above this line
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36.

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

The function you give to sort should return -1 (or a negative number), 0, or 1 (or a positive number)

Yours returns true or false.

Note also sort with no arguments (the default behaviour) will work

how will i make this to return a number as a value.
i did the challenge, just wanted to know how this would work without using default value.
#thanx

You could do it 1 of 3 ways: with a few if commands, a switch block, or a ternary operator. Review the documentation for .sort() and you should be able to arrive at what you’re trying to do.