A search engine website wants implement a new feature that allows their users to sort their search results.
Each search result consists of a URL, a timestamp, and a relevance score. Given an array of results, the name of the column to sort by, and the sort order (ascending or descending), the page number and size of each page, implement a function that returns a list of results.
Input
sortParameter: a number representing the column to sort by: 0 = URL, 1 = timestamp, 2 = relevance
sortOrder: a number representing the sort order: 0 = ascending, 1 = descending
itemsPerPage: the number of results that is required to be displayed on a single page
pageNumber: the page number, starting from 0
items: a map of URLstrings to tuples representing the (relevance, timestamp)
Output
Return a list of URLs to be displayed.
Example:
Input:
sortParameter = 1
sortOrder = 0
itemsPerPage = 2
pageNumber= 1
items= [[“foo.com”, 10, 15], [“bar.com”, 3, 4]. [“baz.com”, 17, 8]]
Output: [“baz”]