[tw5] Re: Sort tiddlers by substring?

2020-09-06 Thread amreus
Eric,

Outstanding.  Thanks for sharing your expertise.

I happen to be using 5.1.23-prerelease, so the new sortsub filter works 
perfectly.  Also thank you for the example of splitting sub-strings using 
split and rest, as well as the technique for creating a temporary list, 
sorting that, and then deconstructing the list.  It's a mini master-class.

On Sunday, September 6, 2020 at 5:45:35 AM UTC-4 amreus wrote:

> Heh, thank. That is exactly my current solution.
>
> I am wondering if there could be a new filter (or option) in the "nsort" 
> family of filters which would ignore any non-number characters.  I looked 
> at the Javascript functions in sort.js and the sortTIddlers function in 
> wiki.js for a clue but I need to study that a bit more to understand how 
> sorting works. 
>
> My initial thought would be to use Javascript's String.replace() to remove 
> any non-numeric characters from the titles and then pass them on to nsort. 
>
> Thanks.
> On Saturday, September 5, 2020 at 6:05:30 PM UTC-4 Mark S. wrote:
>
>> You will likely save yourself hours of headaches if you create separate 
>> fields for id and name.
>>
>>
>> On Saturday, September 5, 2020 at 2:10:56 PM UTC-7, amreus wrote:
>>>
>>> My "people" tiddlers consist of the person's name and an ID number to 
>>> make them unique. How can I sort the tiddlers by the ID number?
>>>
>>> example title: *Karl Roger Stanton (I234)*
>>>
>>> Thanks.
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0d1da7da-167a-42c2-b0d5-e31e01641f52n%40googlegroups.com.


[tw5] Re: Sort tiddlers by substring?

2020-09-06 Thread amreus
Heh, thank. That is exactly my current solution.

I am wondering if there could be a new filter (or option) in the "nsort" 
family of filters which would ignore any non-number characters.  I looked 
at the Javascript functions in sort.js and the sortTIddlers function in 
wiki.js for a clue but I need to study that a bit more to understand how 
sorting works. 

My initial thought would be to use Javascript's String.replace() to remove 
any non-numeric characters from the titles and then pass them on to nsort. 

Thanks.
On Saturday, September 5, 2020 at 6:05:30 PM UTC-4 Mark S. wrote:

> You will likely save yourself hours of headaches if you create separate 
> fields for id and name.
>
>
> On Saturday, September 5, 2020 at 2:10:56 PM UTC-7, amreus wrote:
>>
>> My "people" tiddlers consist of the person's name and an ID number to 
>> make them unique. How can I sort the tiddlers by the ID number?
>>
>> example title: *Karl Roger Stanton (I234)*
>>
>> Thanks.
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ad5841f2-eabe-4bbe-b328-31f2cf1ca354n%40googlegroups.com.


[tw5] Re: Sort tiddlers by substring?

2020-09-05 Thread Eric Shulman
On Saturday, September 5, 2020 at 2:10:56 PM UTC-7, amreus wrote:
>
> My "people" tiddlers consist of the person's name and an ID number to make 
> them unique. How can I sort the tiddlers by the ID number?

example title: *Karl Roger Stanton (I234)*


This is hard to do (but still possible) using the current version of TW 
(5.1.22)

However, it is very easy using the new "sortsub" filter that is available 
in the next update (5.1.23)
currently in "pre-release"... 
see https://tiddlywiki.com/prerelease/#sortsub%20Operator)

Let's start by assuming that all your "people" tiddlers are tagged with 
"people" so you can find them easily.

Then, to sort by ID number extracted from the tiddler titles, use the 
"sortsub" filter, like this:
\define sub() [split[(]rest[]split[)]first[]]
<$list filter="[tag[people]sortsub]">
   <>


Notes:
* The $list finds all "people" tiddlers.
* The sub() macro defines the filter to extract the ID from each title
* The sortsub[] filter uses the extracted ID values to sort the titles in 
ascending order

Here's how to do the same thing using the current TW5.1.22:
\define getList()
<$list filter="[tag[people]]">
   <$vars id={{{ [split[(]rest[]split[)]first[]] }}}>
  <$text text="[["/><>;<><$text text="]]"/>
   

\end

<$wikify name="people" text=<>>
<$list filter="[enlistsort[]]">
   {{{ [split[;]rest[]] }}}



Notes:
* getList() finds all "people" tiddler and, for each, it outputs a string 
of the form: *[[id;tiddlertitle]]*, including the square brackets (to allow 
for titles with spaces)
* $wikify invokes <> and converts the macro output into plain text
* $list enlists this text (converting it to a list of separate items) and 
then sorts it by the ID (which is now a prefix on each title)
* Then, it outputs each item, removing the prefix and the ";" used as a 
delimiter
* The result is the original list of [tag[people]], sorted by ID.

Hope this helps,

-e

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4cb7a361-5b61-4e5c-8921-7678842da954o%40googlegroups.com.


[tw5] Re: Sort tiddlers by substring?

2020-09-05 Thread 'Mark S.' via TiddlyWiki
You will likely save yourself hours of headaches if you create separate 
fields for id and name.


On Saturday, September 5, 2020 at 2:10:56 PM UTC-7, amreus wrote:
>
> My "people" tiddlers consist of the person's name and an ID number to make 
> them unique. How can I sort the tiddlers by the ID number?
>
> example title: *Karl Roger Stanton (I234)*
>
> Thanks.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/077a5ccf-1d2d-4920-84b3-b245030dff68o%40googlegroups.com.