I have an API that returns a list of companies as JSON, structured similar to this:[    {      id: 1,      name: FooCorp    },    {      id: 2,      name: Bar Industries    }   // etc.]This API is called by another application which calculates analytics on the companies. The client application has its own separate database where it stores this information. When it calls the API, it looks up the data it has on a company, creates a new object combining them with the basic information it got from the API, and renders a page to display this combined result.I need to be able to sort the list of combined objects according to the health score, which is something that gets added on the client side. Unfortunately the API results are paginated by database id, so if I just read a page from the API, add the health scores, and sort, I don't get a global sort on all the items, only the items on that page. E.g. I could read results 1-100 from the API and sort, and perhaps the first item, with the lowest health score, would be company #54 with health score 38. But company #107, on the next page of results, could have health score 22, so it should have actually been on the first page of results when sorted by health score, but I won't know about it until I read the second page of results.I can make changes to the API, but the analytics need to stay in the client application, so I can't do the easiest solution of sorting it all on the API. It would be too much work to move the analytics, and it would violate the intentions of the two applications since the one with the API is customer-facing and the client is purely internal. I also can't make the API return the full data set to the client since it's too large, and the results are displayed directly to a user so it needs to be fairly responsive. Under these constraints, how can I achieve a global sort by health score, which is only on the client?
How to implement global sort on items read from a paginated API based on keys which are only available to the client?
design;api;server side