Help with Sorting an Array Alphabetically

Tell us what’s happening:

I got the code from the solution and it still didn’t let me pass. I tried the same code before i got the solution and it still didn’t work.

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
console.log(alphabeticalOrder(["a", "d", "c", "a", "z", "g"]));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:

In bullet points because this has been answered many times on the forums:

  • Solution used by hint now doesn’t work on browsers that changed to use a different algorithm for sort last year, primarily Chrome-based browsers.
  • Hint has been changed but the fix is not live on the site (this has now been in place for almost a year: yes, fixes to the curriculum are slow but it seems to be difficult to deploy new versions).
  • Your solution does not match what the callback to sort should be, check the documentation.
  • Just using sort without a callback works and passes the challenge (eg just default), but you should actually understand what it does before blindly using it.