Exercise: Top articles
Your task is to implement a function; that will return the top articles from the given list. The top articles are those that have the highest number of views. The returned list should have the same order as the given list. The function should return a list of the given size. If the given list is smaller than the given size, it should return all the articles. If the given list is empty, it should return an empty list.
Starting code:
Example usage:
This problem can either be solved in the below playground or you can clone kotlin-exercises project and solve it locally. In the project, you can find code template for this exercise in functional/collections/TopArticles.kt. You can find there starting code, example usage and unit tests.
Hint: The trick to be able to sort by views and then return the original order is to use withIndex
function.
Once you are done with the exercise, you can check your solution here.