Sorting Book Titles: Ignoring Articles
Description:
When sorting lists of book titles alphabetically, articles (the
, an
, or a
) in the beginning of the title should be ignored, and moved to the end.
For example, given a list that contains A Petition to Magic
and Heritage of Deceit
, Heritage of Deceit
should be sorted before A Petition to Magic
.
The remainder of the title should be sorted as if the article was appended to the end of the title.
For example, A Petition to Magic
becomes Petition to Magic, A
for purposes of sorting, and The Great Gatsby
becomes Great Gatsby, The
.
Write a method that receives a list of book titles as strings, and returns a new, sorted list, which follows the above rules.
You should not modify the original title. It should be returned as-is in the resulting list.
If null is passed to the method, it should return null. If an empty list is passed, the method should return an empty list.
Note: only exclude articles if they appear in the beginning of the title. For example, if a title happens to include the word The
in the middle, that word should not be excluded.
Also, do not exclude articles if the entire title is an article (for example, a book titled simply The
should remain The
for purposes of sorting).
Similar Kata:
Stats:
Created | May 3, 2017 |
Published | May 8, 2017 |
Warriors Trained | 251 |
Total Skips | 1 |
Total Code Submissions | 1020 |
Total Times Completed | 95 |
C# Completions | 95 |
Total Stars | 8 |
% of votes with a positive feedback rating | 88% of 45 |
Total "Very Satisfied" Votes | 36 |
Total "Somewhat Satisfied" Votes | 7 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 12 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |