I am looking to sort an array containing movie title strings such as:
['Battleship','101 Dalmatians','Alice, Sweet Alice','40 Days of Night', '303 Fear Faith Revenge'...]
My expected output from this would be:
101 Dalmatians
303 Fear Faith Revenge
40 Days of Night
Alice, Sweet, Alice
Battleship
I am trying the following which gets close:
getMoviesInAlpOrder() {
const movieList = this.getMovies();
return movieList.sort(function(a, b) {
return a.title.toLowerCase() > b.title.toLowerCase();
});
}
This almost works but does have some conflicts when sorting the numbers versus character titles. Any suggestions on how best to handle this type of request?