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