Sorting Categories

Dear all,

I am new to Jekyll and I’m trying to figure out how to get collections to work so any advice would be greatly appreciated

I have been trying to figure out how to sort a collection. I have a collection called galleries and I would like to sort galleries by album. From reading online and this bulletin board I see I can’t use categories or tags but I was wondering is there a way I could create a sort by album are my options
* _galleries/album-name
* _album-name

I would like to have to not create 15 folders at _album-name and some sorting of the galleries would be helpful.

I’m using the mmistakes/minimal-mistakes theme and hosting on github pages if that helps.

I think this might work?

{% assign categories =  site.galleries | map: 'categories' | join: ','  | split: ',' | uniq %}
{% for category in categories %}
  <h3>{{ category }}</h3>
  {% for galleries in site.galleries %}
    {% if galleries.categories contains category %}
    <li><a href="{{ site.baseurl }}{{ galleries.url }}">{{ galleries.title }}</a></li>
    {% endif %}
  {% endfor %}
{% endfor %}