Introduction
So John finally has his holidays! And what better could he do than watching some movies. He indeed has a lot of movies to watch, but he is unable to decide which one to watch first. He has a list of movies, each in the format: <Movie name> (<Year>)
. So he makes a simple set of rules to decide his order of watching movies.
1) The first preference is given to the release year. If a movie released a year or earlier than others, then he would watch them first.
2) If two or more movies released in the same year, and one of them begins with a number, then he would prefer to watch that movie first.
3) If two or more movies released in the same year begin with a number as well, then the movie which comes first on the original list would be watched first.
4) If two or more movies released in the same year begin with a letter, then the movie beginning with a letter which comes earlier in the English alphabet will be chosen first. If two movies begin with the same letter, then the one containing a lesser number of characters in the movie name(including spaces) will be chosen first.
5) If the number of characters is also same, then the movie which comes later in the original list would be watched first.
Well, what a great set of rules indeed. Now the challenge.
Challenge
The input will be a list of movies, i.e, strings - all following the specified format, and you need to output the sorted list, following the above stated rules. Be case insensitive , i.e, treat both uppercase and lower case characters equally and assume all inputs to be valid, and the list will contain no duplicate elements. Also, every character in the movie name is either a letter, or a number and there are blank spaces only in between. You can assume the release year is 4 digits long.
Examples
Input
Output
['The Town (2010)', 'The Prestige (2006)', 'The Departed (2006)']
['The Departed (2006)', 'The Prestige (2006)', 'The Town (2010)']
['Hello (2001)', '15 minutes (2001)', '25 Minutes (2002)']
['15 minutes (2001)', 'Hello (2001)', '25 Minutes (2002)']
['15 (1960)', '25 days (1960)']
['15 (1960)', '25 days (1960)']
['Jjjj (2004)', 'Hello (2004)']
['Hello (2004)', 'Jjjj (2004)']
['all gone (2018)', 'Be careful (2018)']
['all gone (2018)', 'Be careful (2018)']
['Be careful (2018)', 'all gone (2018)']
['all gone (2018)', 'Be careful (2018)']
Scoring
This is code-golf , so the shortest code wins!
<Movie name>
and all the examples are mixed case. \$\endgroup\$