Sort an Array Alphabetically

Hello, I am currently trying to solve the Functional Programming: Sort an Array Alphabetically using the sort Method but it does not want to pass don’t know what is wrong with my code

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

yet I passed it with return arr.sort()!!!
could someone please tell me why!!
Thank you all and happy coding!

that is a browser implementation of sort (using a > b) that is not supported anymore, there has been some delay in updating the curriculum lately
the default behaviour is sorting using the UTF-16 code unit value
to say how to sort you need a callback that returns 1, 0 or -1 (or at least positive, 0, negative number)

1 Like

Thank you for your answer, I really appreciate it.