Sorting projects or repos by stars



Hi, I was requested to do a react test where I need to connect to github api.
So far so good, but there are a few catches.
It asks to get the projects from an org and sort it by stars.

The first issue is that the company I was asked to get the info of just doesn’t have public projects. So I got the company repos. As I got the repos I couldn’t sort it by stars and can’t find the instructions for it anywhere.

Can anyone help me with this? I want to sort an org repos by stars.

Thanks in advance.


@Rodzman, unfortunately there is no API endpoint that will produce a list of an organization’s repositories sorted by the number of stars.

In this case you would need to fetch a list of all organization repositories and do your own client-side sorting of that list based on the stargazers_count field returned in the JSON response.

Does that make sense?


@jamesmartin, yep that makes sense, but I managed to overcome this. Instead of looking for that particular endpoint, I used the “search” specifying the user and then I could sort by stars and desc.
That did the trick for me.

For example:{USER}&sort=stars&order=desc

This provided the list I was looking for. :slight_smile:

Thanks a lot for your answer.