Tiddlywiki Custom Field Sort As Number

407 views
Skip to first unread message

Taylor Jensen

unread,
Jun 20, 2016, 6:21:42 PM6/20/16
to TiddlyWiki
I'm making a TiddlyWiki where some of the tiddlers contain the following fields: `age` `year` `month` `date` corresponding to the date of the tiddler in a fictional universe (hence I can't use the existing date fields, the calendar is different).

I have this code that creates a list and sorts tiddlers more or less correctly by `age`, `year`, `month`, `date` in that order:

    <$list filter="[tag[history]] [tag[progress]] +[!sort[date]!sort[month]!sort[year]!sort[age]]">
    <$link>{{!!title}}</$link> | <span style="font-weight: bold;">Age:</span> {{!!age}} <span style="font-weight: bold;">Year:</span> {{!!year}} <span style="font-weight: bold;">Month:</span> {{!!month}} <span style="font-weight: bold;">Date:</span> {{!!date}}<br>
    </$list>

But when I have a field that is say `month:11` it gets sorted after `month:1` and before `month:2` because it's being evaluated and sorted as text.

So my question comes down to how can I force `sort[]` to treat its parameter like an integer, or how can I tell TiddlyWiki what kind of data I'm storing in my custom fields?

Mark S.

unread,
Jun 20, 2016, 6:25:41 PM6/20/16
to tiddl...@googlegroups.com
I don't understand all those reverse sorts you're doing, but then again, there's a lot I don't understand ;-)

I think you want the "nsort" operator.

Good luck!
Mark

Taylor Jensen

unread,
Jun 20, 2016, 6:27:49 PM6/20/16
to TiddlyWiki

It's so I get the most recent events first.

nsort sounds like the exact thing I want. Will verify shortly.


On Mon, Jun 20, 2016, 6:25 PM 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
I don't all those reverse sorts you're doing, but then again, there's a lot I don't understand ;-)
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/THfg1qcl3AE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4fe2b637-1633-4b25-87c4-81affe2d166f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

-TCJ

Taylor Jensen

unread,
Jun 20, 2016, 6:40:39 PM6/20/16
to TiddlyWiki
Yup, nsort is exactly what I need. Thanks so much!


On Monday, June 20, 2016 at 6:27:49 PM UTC-4, Taylor Jensen wrote:

It's so I get the most recent events first.

nsort sounds like the exact thing I want. Will verify shortly.


On Mon, Jun 20, 2016, 6:25 PM 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
I don't all those reverse sorts you're doing, but then again, there's a lot I don't understand ;-)

I think you want the "nsort" operator.

Good luck!
Mark


On Monday, June 20, 2016 at 3:21:42 PM UTC-7, Taylor Jensen wrote:
I'm making a TiddlyWiki where some of the tiddlers contain the following fields: `age` `year` `month` `date` corresponding to the date of the tiddler in a fictional universe (hence I can't use the existing date fields, the calendar is different).

I have this code that creates a list and sorts tiddlers more or less correctly by `age`, `year`, `month`, `date` in that order:

    <$list filter="[tag[history]] [tag[progress]] +[!sort[date]!sort[month]!sort[year]!sort[age]]">
    <$link>{{!!title}}</$link> | <span style="font-weight: bold;">Age:</span> {{!!age}} <span style="font-weight: bold;">Year:</span> {{!!year}} <span style="font-weight: bold;">Month:</span> {{!!month}} <span style="font-weight: bold;">Date:</span> {{!!date}}<br>
    </$list>

But when I have a field that is say `month:11` it gets sorted after `month:1` and before `month:2` because it's being evaluated and sorted as text.

So my question comes down to how can I force `sort[]` to treat its parameter like an integer, or how can I tell TiddlyWiki what kind of data I'm storing in my custom fields?

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/THfg1qcl3AE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
--

-TCJ

Duarte Farrajota Ramos

unread,
Jun 20, 2016, 6:45:31 PM6/20/16
to TiddlyWiki
Damn! I was madly searching precisely for this a few weeks ago and never found a solution. Didn't know about nsort, just assumed there was no way to sort numbers in tiddlywiki.
This would have saved me a lot of time then, now waste time again to fixing it... oh well always learning.

Anyway thanks for the tip
Reply all
Reply to author
Forward
0 new messages