Toggle sort text lines in clipboard Aa-Zz ⇄ Zz-Aa

oh sorry I sent the wrong screenshot.

That's what I thought I would see. The problem is that you want to sort based on the hyperlink, but as you can see from the hex dump, your source data doesn't contain the hyperlink anymore. However you created that text, all you are left with is the "display text." Can you see that there is no hyperlink in there? Therefore it's impossible to sort using the hyperlink data.

I think the next step is to explain where you got your links from, and what you did to post them in your screenshot above. Whatever you did deleted the hyperlink data. Until you get the links, you cannot sort on the links.

1 Like

My impression is that the OP is:

  1. Starting with RTF text, and
  2. (inadvertently) creating a plain text derivative which drops the hyperlink layer
  3. getting the impression that that loss took place during the plain text sort.

I suppose one alternative might be:

RTF -> Markdown with [Label](URL) links -> Sorted Markdown with those links -> RTF

i.e. what they may effectively be looking for is something like:

RTF -> Markdown conversion, and
Markdown -> RTF conversion.


Pandoc ?

Yes! That's why I had him provide the dump. I was planning to come up with a sort mechanism using the markdown syntax you are referring to, once he fixed his input data. But I'll defer to you now.

1 Like

Go for it !

@reicc, as @ComplexPoint suggested, you could convert your RTF source to Markdown syntax which is possible. I found a post on this forum which explains how to do that:

If you can manage that, and place your text into a variable named MyResult, then the next step would be to sort the lines based on the URL, which would be quite easy, probably using an Execute Shell script roughly this simple.

image

The above action would sort them by URL. Now the next step depends upon what you want to do. You could either convert the Markdown back to RTF, or if you don't really care about the hyperlink at this point in time, you could just strip it out, probably like this, which gets rid of the text you don't want:

image

But in summary, you can't sort by URL until the URL is part of your input data, and as the dump showed, you removed the URL in your example. You have to find a way to get that data back. Perhaps if you tell us what you did to strip out the URL, we might see a way to save the URL.

@reicc

Perhaps, for example, copying from RTF, but then doing something (like assigning to a plain text KM variable) which effectively selects the

  • public.utf8-plain-text rather than
  • public.rtf

pasteboard item from those available in the clipboard.

That's exactly what I suspect he did, but we might as well wait to hear it from him.

1 Like