How to sort/order an array by size/number of posts contained


#1

I wonder if anyone ever tried this. I wanted to sort/order content according to the size of “posts” content “in” them?

So, I have this structure:
Notes: (a collection like a blog)

  • Series (each post must be categorized to a Series)
  • Posts

Here’s a typical post’s front-matter:

---
title: Usability Problem
headline: Apple's usability problem
description: Apple's products don't naturally talk to each other. It's a usability problem.
date: 2019-01-22
image: '{{site.url}}/uploads/posts/apple-dongles.jpg'
image_title: A plethora of Apple dongles
image_description: A plethora of Apple dongles
image_credit: "Image: Gavin's Gadget"
series: Commentary
---

Thus, this particular post has the Commentary series.

Now on the Notes (blog) archive, I’m outputting all the Series and then showing their size, each for each, showing what number of posts they contain each.

Now the default sort/oder in Liquid/Ruby is alphabetical. What I want is to sort according to the size of each Series, that’s the Series with the most posts should come first and so on, like 7, 6, 5, 4, etc. You get the idea?

Has anybody tried this? I don’t seem to be able to crack it, as if Liquid is not cut out for such.

Thanks.


#2

Perhaps a modified version of this with the addition of the sort filter will get it done.


#3

Just read through. It’s not what I’m trying to do. But thanks.