number ranking

71 views
Skip to first unread message

Peter Buyze

unread,
Apr 29, 2020, 4:11:12 AM4/29/20
to TiddlyWiki forum
I have a field called "number", in which I add a different value for each tid. The value format is "nx", e.g. n5, n37, etc. The tids with these numbers are listed in a separate tid with the following code/script:

<$list filter="[all[tiddlers]each[number]sort[number]get[number]]" variable=value >
__<<value>>__<br>
<$list filter='[all[tiddlers]number<value>sort[]]'>

</$list>
</$list>

So they are sorted numerically, which means n5 and its associated tid title is above n37 and its associated tid title. Duh.

But …… n18 is above n5, which indicates to me that the macro only looks at the 1st digit after the "n". I tried putting n18 between double square brackets, or to write it as n.18, but to no avail.

What do I need to add to the script?


--
Securely sent with Tutanota. Get your own encrypted, ad-free mailbox:

Peter Buyze

unread,
Apr 29, 2020, 6:53:15 AM4/29/20
to 'Peter Buyze' via TiddlyWiki
Even if I leave the "n" off, 18 is still ranked above 5.


29 Apr 2020, 11:11 by tiddl...@googlegroups.com:
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Birthe C

unread,
Apr 29, 2020, 6:57:18 AM4/29/20
to TiddlyWiki
Sure, but it would not over 05. But then you would consider - are you goind to 100 or more and take care of that.


onsdag den 29. april 2020 kl. 12.53.15 UTC+2 skrev Peter Buyze:
Even if I leave the "n" off, 18 is still ranked above 5.


29 Apr 2020, 11:11 by tiddl...@googlegroups.com:
I have a field called "number", in which I add a different value for each tid. The value format is "nx", e.g. n5, n37, etc. The tids with these numbers are listed in a separate tid with the following code/script:

<$list filter="[all[tiddlers]each[number]sort[number]get[number]]" variable=value >
__<<value>>__<br>
<$list filter='[all[tiddlers]number<value>sort[]]'>

</$list>
</$list>

So they are sorted numerically, which means n5 and its associated tid title is above n37 and its associated tid title. Duh.

But …… n18 is above n5, which indicates to me that the macro only looks at the 1st digit after the "n". I tried putting n18 between double square brackets, or to write it as n.18, but to no avail.

What do I need to add to the script?


--
Securely sent with Tutanota. Get your own encrypted, ad-free mailbox:


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Peter Buyze

unread,
Apr 29, 2020, 7:12:44 AM4/29/20
to TiddlyWiki forum
Good point, I have added the zero, and now n05 is above n18.

The list looks like n01, n02, etc. .... n10, n11, n187, n20.

So, the code looks at the 1st digit to determine the initial position, and only if the 1st digit is the same between 2 numbers will it look at the 2nd digit.

What I'll do is place a 9 before the 1st of the 3 digits, so n187 becomes n9187 and that way all the numbers between 100 and 360 will be in the right order.

It's a workaround but that's all I can think of.
Thanks for triggering that with the 0 (zero) suggestion, Birthe.


29 Apr 2020, 13:57 by strikke...@gmail.com:
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

TonyM

unread,
Apr 29, 2020, 9:10:55 AM4/29/20
to TiddlyWiki
Peter

Have you tried nsort rather than sort?

it is designed for numbers but I am not sure how it will respond to your lead in "n".

Never the less, I think your leading zeros is a good idea. I have a nice trick for generating leading zeros I will post if you want when at my desktop.

Regards
Tony

Riz

unread,
Apr 29, 2020, 10:53:43 AM4/29/20
to TiddlyWiki
Do not use sort. Use "sortan" operater. It is specifically made for this.

Peter Buyze

unread,
Apr 29, 2020, 11:02:03 AM4/29/20
to TiddlyWiki forum
Wow Riz, many thanks. Yes, that works. No need for a workaround anymore!!
Others will be able to benefit from this tip too, I am sure.



29 Apr 2020, 17:53 by madapeed...@gmail.com:
Do not use sort. Use "sortan" operater. It is specifically made for this.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages