I have the following code:
function compare(a,b) {
if (a.title < b.title)
return -1;
if (a.title > b.title)
return 1;
return 0;
}
.
.
setsArr.sort(compare);
This should sort an array objects alphabetically based on their title property. When there is a space in the title, however, that title will come before the other titles with no space in them unless those titles start with a number or a special character.
An example of the ordered list could be:
3xd
My Little Pony
Aladdin
Batman
I would like 'My Little Pony' to come last. How could I accomplish this?