Custom ordering in for loop

Hi there, I have page where I’m displaying list of github libs like this:
-```
{% for p in page.find(’/libraries’).header.libraries %}

{{ p.title }}

{{ p.description|markdown }}
{% endfor %} ```

libraries are stored in .md file like this:

libraries:
  - title: "Spring"
    category: animation
    description: "A library to simplify iOS animations."
    link: https://github.com/MengTo/Spring

I’ve found that I can easily show stars of particular library like this:

{{ github.client.api('repo').show('getgrav', 'grav')['stargazers_count'] }}

How can I order my list of libraries based on stars of each library?

You probably need to build a plugin to do that. That plugin should listen for the onPageInitialized event, get the libraries from the page header, get the stargazers count from GitHub, then reorder and make the new object available to be used in the page.

Yeah, I was afraid there won’t be easier solution, I guess I’ll have to learn plugins then :slight_smile: