Bug in sample code for alphabetical array sort?

Hello All,

In the sample code for the Functional Programming: Sort an Array Alphabetically using the sort Method exercise, I believe the comparison function for the reverse alphabetical is incorrect and it doesn’t actually sort the array:

function reverseAlpha(arr) {
  return arr.sort(function(a, b) {
    return a < b;
  });
}

It should be something like this…

function reverseAlpha(arr) {
  return arr.sort(function(a, b) {
    return a > b ? -1 : 1;
  });
}

If I’m not off base, could someone please update it?

Thanks!

You’re right! We actually have an improved version of this challenge which will be part of the next FCC update.

Okay, great. When will that be released, out of curiosity?

I’m not sure. I think that they’re in the QA process - finding and fixing bugs and making sure it’s ready for the full load of millions of eager students.