New topic Closed topic
avatar image
1
Liquid: Sorting case-insensitive
By Created , last editted

Hi,

I am sorting a collection of objects on a specific property. Unfortunately this is case-sensitive. This causes for example a list of [b1 c1 A1 a2 C2 B2] to be sorted as A1,B2,C2,a2,b1,c1 instead of A1,a2,b1,B2,c1,C2.


There is a function called 'sort_natural' in liquid, but does not work/is not yet implemented in the Betty Blocks platform (feature is requested).


My current options are:

- ensure that all the core values stored in the source model are capitalized. So each string start with one capital letter. Or using a regex to start each word within the string with a capital letter.

- extend the source models with specific downcased expression properties for sorting. For example: name/sort_name, city/sort_city.


But this causes in principle unnecessary duplication of data or unnecessary load on performance 


So I am looking for a way make the liquid sort function to be case-insensitive.  Possible by adding a custom sort column using liquid. 


Any thoughts?



Hi,

I am sorting a collection of objects on a specific property. Unfortunately this is case-sensitive. This causes for example a list of [b1 c1 A1 a2 C2 B2] to be sorted as A1,B2,C2,a2,b1,c1 instead of A1,a2,b1,B2,c1,C2.


There is a function called 'sort_natural' in liquid, but does not work/is not yet implemented in the Betty Blocks platform (feature is requested).


My current options are:

- ensure that all the core values stored in the source model are capitalized. So each string start with one capital letter. Or using a regex to start each word within the string with a capital letter.

- extend the source models with specific downcased expression properties for sorting. For example: name/sort_name, city/sort_city.


But this causes in principle unnecessary duplication of data or unnecessary load on performance 


So I am looking for a way make the liquid sort function to be case-insensitive.  Possible by adding a custom sort column using liquid. 


Any thoughts?


Answers
Sort by:

This topic is closed.