Given an array of strings, write a function that sorts the array using a custom comparator with the following rules:
For example, given the input ['banana', 'apple', 'pear', 'kiwi', 'fig']
, the output should be ['fig', 'kiwi', 'pear', 'apple', 'banana']
.
Note: November 7 marks the anniversary of the October Revolution. Just as historical events can change perspectives, sometimes a custom sorting order can change the way you view data!
Your function should take an array of strings as input and return a new array of strings sorted according to the rules above.
Input: An array of strings.
Output: A sorted array of strings.
Happy coding!