reverse (retrograde) sorting under F9
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 5
- Joined: Fri Jul 20, 2007 11:55 am
reverse (retrograde) sorting under F9
As a Dutch lexicographer and developer of medical dictionaries and a medical spellchecker, I use TextPad for coding and sorting lexical data. I would be greatly helped with an option under F9 for sorting lines in reverse order (retrograde). Is this an option that will be appreciated by others too and could it possibly be included in a future version? For this purpose I now have to resort to WordSmith, a linguistic tools suite that requires a lot of data preprocessing before obtaining the desired result.
Regards,
Arnoud
Regards,
Arnoud
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
-
- Posts: 5
- Joined: Fri Jul 20, 2007 11:55 am
reverse (retrograde) sorting under F9
Hi Bob,
Thanks for suggesting. No, that is not what I mean. Consider:
- ascending sorting: Bob | Dick | Harry | John | Paul
- descending sorting: Paul | John | Harry | Dick | Bob
- sorted reversely, you would get: Bob | Dick | Paul | John | Harry, based on the names' last letters, here resp. b, k, l, n, y.
Regards,
Arnoud
Thanks for suggesting. No, that is not what I mean. Consider:
- ascending sorting: Bob | Dick | Harry | John | Paul
- descending sorting: Paul | John | Harry | Dick | Bob
- sorted reversely, you would get: Bob | Dick | Paul | John | Harry, based on the names' last letters, here resp. b, k, l, n, y.
Regards,
Arnoud
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
In Perl:
although that won't scale well for very large files.
Code: Select all
print sort { ( reverse $a ) cmp ( reverse $b ) } <> ;
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Ah, I see.
To sort the |-separated items on each line you might need something like:
No problems there with scalability.
To sort the |-separated items on each line you might need something like:
Code: Select all
for my $line ( <> )
{
chomp $line ;
$line =~ s/ +$// ;
my @elems = split ' *\| *', $line ;
my @sortedElems = sort { ( reverse $a ) cmp ( reverse $b ) } @elems ;
my $sortedLine = join ' | ', @sortedElems ;
print "$sortedLine\n" ;
}
-
- Posts: 5
- Joined: Fri Jul 20, 2007 11:55 am
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I doubt it; this is a very special-purpose requirement. If every such special need were catered for directly, TextPad's code and user interface would bloat hugely.
If your work involves much text handling you will find it extremely useful to have at your disposal a general-purpose language with powerful text handling facilities, such as Perl, Python, Ruby, Tcl, or what you will. Otherwise you will always be restricted to whatever was thought of or thought to be important by the author of the limited-functionality tools you use.
Unfortunately, TextPad does not support the writing of scripts in any language. Requirements like yours are a good argument for the inclusion of this functionality.
BTW, why do you want to order words (or lines) in this way?
If your work involves much text handling you will find it extremely useful to have at your disposal a general-purpose language with powerful text handling facilities, such as Perl, Python, Ruby, Tcl, or what you will. Otherwise you will always be restricted to whatever was thought of or thought to be important by the author of the limited-functionality tools you use.
Unfortunately, TextPad does not support the writing of scripts in any language. Requirements like yours are a good argument for the inclusion of this functionality.
BTW, why do you want to order words (or lines) in this way?
(Yes, I realize this is a VERY old thread)
given this list of names:
bob
cindy
mel
barbara
gene
find ------------ ^(.*)(.)$
replace --------- \2 \1\2
take note of the SPACE following the initial "backslash two"
ReplaceAll
the result:
b bob
y cindy
l mel
a barbara
e gene
Next, Tools } Sort produces:
a barbara
b bob
e gene
l mel
y cindy
Then
find ---------- ^.[ ]
replace ---------- leave empty
ReplaceAll
Now we have the "retrograde sorted" list:
barbara
bob
gene
mel
cindy
given this list of names:
bob
cindy
mel
barbara
gene
find ------------ ^(.*)(.)$
replace --------- \2 \1\2
take note of the SPACE following the initial "backslash two"
ReplaceAll
the result:
b bob
y cindy
l mel
a barbara
e gene
Next, Tools } Sort produces:
a barbara
b bob
e gene
l mel
y cindy
Then
find ---------- ^.[ ]
replace ---------- leave empty
ReplaceAll
Now we have the "retrograde sorted" list:
barbara
bob
gene
mel
cindy