Composing titles that appear at the end of the "All" listing

Sorry not sure what you mean?

  • The lowercase is coming before upper case in this string based sort.
  • Would you prefer the otherway?
  • I have no problem which is first only that they appear near each other.

Here is the result from my test data

You said:

a-z Alphabetics lowercase firstthen uppercase for each letter

Your $list enumerates ASCII codes 32 .. 126, therefore, ASCII code 65 (uppercase ‘A’) comes BEFORE ASCII code 97 (lowercase ‘a’). So, it’s uppercase first, then lowercase.

And you said it twice, so I’m not sure what you’re referring to, but your code (and ASCII itself) is pretty clear.

The list widget enumerates the ASCII characters so you can see what they are, I then go on to explain the sort order as a result of using the filter run :sort: string[get[title]] behaves.

  • The emphasis is on with useful differences

It is not as simple as the ASCII table because we would not want a lowercase a to come after an uppercase Z for example.

  • The key point here is it not only satisfies the OT but also the need for other punctuation characters that appear before after numbers and alphanumetics in the sort, or the number 10 to come before 1 etc…
  • Now by choosing the right character as a prefix to a tiddler title, you can ensure where it comes in the order of things.
  • The main relationship to the ASCII table is you can see the cluster and order of symbols available in each relative position.

Here is a test sample of tiddlers you can drop on tiddlywiki.com to test different sort methods. character-prefixed-titdlers.json (1.8 KB)

No, no, that is not the point. Please, pay attention, Tones

Your code

<$list filter="[range[32],[126]]" variable=ascii>
   <<ascii>> {{{ [charcode<ascii>] }}}<br>
</$list>

Try it on TW .com ← Uppercase FIRST.

@CodaCoder see my screen shot above, the result has modes before Modes.

As I said it is not important the order of a-z and numbers, in the ASCII table when you use the recommended sort method the result is what I have stated.

  • it becomes aA - zZ and 1-9 before 10-19 as is expected normally.
  • It is clearly handled internally perhaps by the javascript function that is being used.

Yes the ASCI List does return
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~

  • Note I removed backtick, and would not recommend | [ ] { } as tiddlywiki tells you.

@CodaCoder have you not seen what I am saying?

I did not deserve the “Please, pay attention, Tones” perhaps that was for you?

For any future testing here is some test data;

sample-character-prefixed-tiddlers.json (17.6 KB)

Drop on empty and use to list

<$list filter="[tag[Prefixed tiddler set]]  :sort:string[get[title]]">

</$list>

I have now found numbers failing to sort correctly. 1 10 100 come together. as do 2 20 and 200

  • Odd I missed this :frowning:

It has “modes” before “Modes uppercase”. But that’s different. It’s similar to how “AB” sorts before “ABC”. If you try “Modes” and “modes”, you’ll see that upper-case sorts first.

As to numbers, that’s a much harder sorting problem. Normal sorting is character-by-character lexicographic. To handle numbers properly, you’d have to chunk the digits together and convert them to numbers. It’s an interesting problem that’s certainly been solved, but I’ve never looked for (or tried to write) a solution.

Hmmm…

Never mind, it’s been solved, and is built into the language:

This is probably too new to be allowed in the TW core, but could probably be a plugin.

Again, never mind. This is built in:

https://tiddlywiki.com/#sortan%20Operator

<$let my-list="ABC-12 ABC-3 ABC-20 ABC-3.141592 ABC-2.71828 ABC-3-XYZ">
''Unsorted'': <$text text={{{ [enlist<my-list>join[, ]] }}} /><br/>
''sort'': <$text text={{{ [enlist<my-list>sort[]join[, ]] }}} /><br/>
''sortan'': <$text text={{{ [enlist<my-list>sortan[]join[, ]] }}} /><br/>
</$let>
unsorted ABC-12 ABC-3 ABC-20 ABC-3.141592 ABC-2.71828 ABC-3-XYZ
sort ABC-12 ABC-2.71828 ABC-20 ABC-3 ABC-3-XYZ ABC-3.141592
sortan ABC-2.71828 ABC-3 ABC-3-XYZ ABC-3.141592 ABC-12 ABC-20

@Scott_Sauyet Your results as a markdown table

unsorted sort sortan
ABC-12 ABC-12 ABC-2.71828
ABC-3 ABC-2.71828 ABC-3
ABC-20 ABC-20 ABC-3-XYZ
ABC-3.141592 ABC-3 ABC-3.141592
ABC-2.71828 ABC-3-XYZ ABC-12
ABC-3-XYZ ABC-3.141592 ABC-20

How to…

| unsorted | sort | sortan |
|---|---|---|
| ABC-12 | ABC-12 | ABC-2.71828 |
| ABC-3 | ABC-2.71828 | ABC-3 |
| ABC-20 | ABC-20 | ABC-3-XYZ |
| ABC-3.141592 | ABC-3 | ABC-3.141592 |
| ABC-2.71828 | ABC-3-XYZ | ABC-12 |
| ABC-3-XYZ | ABC-3.141592 | ABC-20 |

Ha! Just saw your update. Mine’s pivoted, I’ll leave it :wink:

1 Like

Damn, I just altered that, but did it sideways and was going to revert because it didn’t really work.

Note that you can also use the :sort:alphanumeric[...] filter run prefix.
see https://tiddlywiki.com/#Sort%20Filter%20Run%20Prefix

I’m bummed I didn’t see this thread earlier.

I’m not sure if it works on other platforms, but it’s easy to type omega Ω on a mac. It’s opt-z (where opt is like alt on pc).

I’ve been using it as a prefix for years, when I quickly need to send something to the end of an alphabetical list.

And, of course, it’s easy to remember as “the end”!

-E

When it comes to sorting the placement of special characters to force titles to the top/bottom works well with string sort. Numbers and alphanumeric have their uses.

It seems that we dont have a single sort method that can order any posible title all at once in an order we may expect in a reference work.

I would hope there was a javascript function for this or perhaps we could make one.

I have tried to apply different sorts to titles with numbers for example. This would be easier if we had the reverse of the charcode operator because could detect in which range the first character resides. But then we have trailing numbers.

The devil is in the details.

I may be missing the point. I think alphanumeric (or sortan) is pretty close. The only missing part (for English, anyway) is the skipping of initial “A”, “An”, and “The”. Do you see other objections to it?

If we do need to extend our sorting capabilities further, now that we have functions, perhaps we can have a version that puts the user in full control the way JS’s Array.prototype.sort does: we pass a function that takes two parameters and returns a negative number if the first one is smaller, zero if they’re equal, and a positive number if it’s larger. (Or equivalently, a function that takes two parameters and returns yes if and only if the first one is smaller; this might be more palatable to non-programmers, and it’s implementation is not much more difficult.) sortsub gets us part of the way; but it requires us to construct a sort key. This would offer complete control. Note that I may be misunderstanding how the new functions work, though.

I need to focus on this again, but not for now, to revisit. But the sort filter run string orders tiddlers with special characters correctly allowing tiddlers to starting with such special characters to appear at the top or bottom, before or after numbered prefixes and alphanumeric.

  • As I said we could first separate titles as beginning with a special character, alpha or numeric we could get the result I, and I believe the OT is asking for. That is we divide the list and “subsort” as desired.
  • unfortunately there is devils in the details. I have 98% of the solution then found it had limitations.
  • I was aiming for something similar to
    • Using the string approach for special characters
    • Alphanumeric for alpha+
    • Number for leading integers?

By the way we have removed the “stop words” in a solution before, “A”, “An”, and “The” you mention.

I was mistaken thinking there was an easy solution already available, I am confident there is a work around but we do need easier solutions in this space. However this area is driven by diverse preferences, potential complexity and many almost solutions.

Yes, my thought is as I mentioned the reverse of the charcode operator may assist here, given a character return the charcode number. We can then leverage the order of different groups (in the character table) according to the starting character.

  • This should be easy and is possibly already available to JavaScript.
  • Actualy when looking for charcode in the core I noticed some of the encode/decode operators may allow use to do this. Needs more research.
    • Perhaps we write our own encodeASCII or similar then we can access the natural order where needed, or classify a title based on its first character.

charcode-of.json (1.1 KB) (requires reloading)

* `"A"`: <$text text={{{ [charcode-of[A]] }}} />
* `"a"`: <$text text={{{ [charcode-of[a]] }}} />
* `"~"`: <$text text={{{ [charcode-of[~]] }}} />
* `"_"`: <$text text={{{ [charcode-of[_]] }}} />
* `"Ω"`: <$text text={{{ [charcode-of[Ω]] }}} />
  • "A": 65
  • "a": 97
  • "~": 126
  • "_": 95
  • "Ω": 937

Thanks Scott, this is just what I wanted.

  • It also works beyond 256 even further into the Unicode sets. {{{ [charcode-of[∞]] }}}
  • And with Unicode I find the encodeuri operator shows the multi-byte representation

Perhaps others can suggest alternate names to charcode-of?, I am thinking or charnum, but there is a wisdom in the crowd.

  • however we may also want a version like the encode and decode operators that act on the input titles.
  • Then I would suggest you submit it to the core?

:+1:

It was a quick bit, and I didn’t think too hard about the name. I agree that charcode-of is not wonderful. But I still don’t have anything better. It’s built upon the JavaScript String method called charcodeAt, but that has an integer parameter denoting the index inside the string you want to check. We could go that way, and it would be easy enough to do, but it would add complexity to the use of it.

Possibly, but I’m not really sure how we’d use the returned list of numbers, and if they were run on a list of titles, then we’d have to deal with lists of lists of numbers. There may be useful things to do on such, but I have not used them – not even seen them – in my months of TW immersion.

Sure. It’s an easy addition to make. But I think we’d need to spend more time hashing out exactly what’s needed. This was a first pass.