A similar question was asked here.
Since the values are likely being treated as strings the order isn't based on numeric values (but string values).
This is verbose code I've just smashed out that for production would need to be cleaned up, added whitespace control and made more efficient - but should be easier to read for this thread.
{% assign myArray = "11,7,4,3,12,9,2,8,6,10,1,5" | split:"," %} {% assign myNewArray = "" %} {% assign zeroFill = "00000000" %} {% for i in myArray %} {% assign thisFill = zeroFill | slice:i.size, zeroFill.size %} {% assign newValue = thisFill | append:i | append:"," %} {% assign myNewArray = myNewArray | append:newValue %} {% endfor %} {% assign myNewArray = myNewArray| split:"," | sort %} {% for i in myNewArray %} {{ i | abs }}<br /> {% endfor %}
Does that help?
I also touch on something similar here.
https://freakdesign.com.au/blogs/news/sort-products-in-a-shopify-collection-by-metafield-value-without-javascript
He adds zeros to each number in order to work around the issue.