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

@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.

I am presently using the charcode-of to control the sort order according to the first character.

This may in part inform;

[Edited]

  • I have a solution that works, but I am now trying to simplify / modularise it, it is dependant on charcode-of[]
  • Idea: A form of is operator that returns a set name for a set of characters eg is.numeric.prefix() and if it is, return a set name such as numeric / alphanumeric / string which is the appropriate sort order.
1 Like