Skip to content

Instantly share code, notes, and snippets.

@brennandunn
Created May 20, 2020 03:06
Show Gist options
  • Select an option

  • Save brennandunn/c95e1fa8e8b7a766892ee118fa1689cc to your computer and use it in GitHub Desktop.

Select an option

Save brennandunn/c95e1fa8e8b7a766892ee118fa1689cc to your computer and use it in GitHub Desktop.

Revisions

  1. brennandunn created this gist May 20, 2020.
    12 changes: 12 additions & 0 deletions field_sorting_liquid
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {% capture tuples %}
    {{ subscriber.field_a }},field_a|
    {{ subscriber.field_b }},field_b|
    {{ subscriber.field_c }},field_c|
    {{ subscriber.field_d }},field_d
    {% endcapture %}

    {% assign sorted_tuples = tuples | split: "|" | sort | reverse %}
    {% for tuple in sorted_tuples %}
    {% assign tuple_array = tuple | split: "," %}
    {{ tuple_array[1] }}: {{ tuple_array[0] }}
    {% endfor %}