Ignore case in template query order by?

Hi, I’m using a template with a query to find pages in directories and list them on my index page. Likes this:

\```template
| Name | Date | Size |
|---|----|----|
{{{page select page where name =~ 'Linux' select name, lastModified, size order by displayName asc render [[Library/Core/Query/ListPagesLastMod]] }}}
\```

The ListPagesLastMod.md contains this:

---
tags: template
description: A page reference link as a list item
---
| [[{{name}}]] | {{lastModified}} | {{size}} |

However, some page names start with a lower-case letters, some start with upper-case ones, and this breaks the sort (because lowercase a comes after uppercase Z, code-wise).

My question is: Is there a way to ignore case when sorting?

Thanks.

P.S.: I found this thread LIQ order by is affected weirdly by case - v2: Troubleshooting - SilverBullet Community but I’m unsure how to apply to the template-type query I’m using. Yes, my skill level is fairly low in this, sorry for potentially missing something obvious. Thanks for your patience and help :slight_smile:

I don’t know what the best way was here, but something like this should work.

silverbullet.registerFunction({name: "toLowerCase"}, (str) => {
  return str.toLowerCase();
})
page order by toLowerCase(name) limit 10

I’m using past tense as it would probably be best to update to v2 sooner or later as v1 is slowly getting phased out. And in v2 stuff like this is much nicer as you have seen.

Hi @MrMugame , thanks for the function. Could you please elaborate a little but on where should I place the function definition so that I can use it in the template macro? It seems I can’t simply put it somewhere into the macro as I get a syntax error when I do so.

Also, thanks for reminding me there’s the v2 - if I read the announcement correctly, I’ll have to wait until upgrade for “pure Deno” deployment is covered as well.

It‘s a space script I‘d recommend you read the docs on that. They are getting phased out tho.

Afaik there won‘t be a „pure deno“ way to install silverbullet going foward. But there are binaries.

IC, thanks, sorry for missing that. I’ll look into it and consider the Docker image.

1 Like