Fetch Items To Display

We sort the results by the sortColumn and order. Then using the pageSize and the pageIndex, we can figure out the number of results on the previous pages and the index of the first result of the target pageIndex page. For example, pageIndex = 1 and pageSize = 2, there are 1 * 2 = 2 results on page 0 so the index the first result of page 1 should be 2. Finally we return all the results on the target page.

This is a companion discussion topic for the original entry at https://algo.monster/problems/fetch_items_to_display/