Julius Hamilton said on Tue, 14 Sep 2021 13:57:34 +0200
I think you're using the wrong tool. Also, you haven't said why you
need Vim tags on lines. If I'm not mistaken, there are only a limited
number of tags, and if you have that few lines, you're better off doing
this all manually.
Anyway, the tool I'd use is AWK. Not one liners, but real AWK programs.
My first step would be to put every about 3 underscores followed by
the line number at the end of every line, but add one million to
the line number so all line numbers have the same length. This is
trivial in AWK. Now you have a record of the original sort order.
Next, I'd perform whatever kind of two stage or branched sorting you
need to do, once again with AWK.
Next, do whatever you need to do in order to simulate Vim tags. Because
you haven't told us what the tags are used for, I can't comment further.
Next, do whatever you need to do with those simulated tags.
Finally, within Vim, move the ending line numbers to the front of each
line, and re-sort again, to put it in the original order. Finally, use
Vim to get rid of those line numbers.
SteveT
Steve Litt
Spring 2021 featured book: Troubleshooting Techniques of the Successful
Technologist
http://www.troubleshooters.com/techniques