Of course, I would consider the Google API as "limited."
In general, the comparison functions used for sorting algorithms are very βbinaryβ:
- input: 2 elements
- output: true / false
Here you have:
- input: 5 elements
- conclusion: relative weights of each element
Therefore, you only need a linear number of API calls (whereas sorting usually requires O (N log N) calls for comparison functions).
You will need the ceil( (N-1)/4 ) tags. This can be parallelized, although carefully read the user manual, as well as the number of requests that you are allowed to send.
Then, as soon as they are all "rated", you can have a simple view in local.
Intuitively, to assemble them correctly, you would:
- Shuffle your list
- Complete the first 5 elements
- API call
- Paste them into the result (use the insert here)
- Choose a median
- Complete the first 4 elements (or fewer if fewer)
- Call the API with the environment and those first 4
- Return to Paste until you finish the items.
If your list is 1000 songs long, it's 250 API calls, no big deal.
Matthieu M.
source share