I have a list of strings which are Guids. I want to return them in sorted order in a api and I want to return 1000 Guids at a time. So, I may have a list of 20000 guids and I want to return them in sorted manner 1000 Guids at a time. I thought of using PriorityQueue and get first 1000 elements. How shall I get next page size from PriorityQueue (from 1000 to 2000, from 2000 to 3000).
The reason I want to use priority queue is because I want it to be performant. I don't want to sort using simple list and take n elements based on page number.
Also, I want to get any suggestion, if someone has any other data structure in getting list of subscriptionIds in sorted manner by pages.
There's a lot to unpack here...but I'm going to assume that you don't actually want a priority queue because nothing in your question dictates an actual priority or a FIFO queue.
On the back end, sort your Guids however you see fit. This will sort them:
var sorted = guids.OrderBy(i=>i).ToList();
Then in your API you can accept a 'page' number, and return the results based on the page
return guids.Skip((page-1)*1000).Take(1000).ToList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.