ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

sorting units of text

<< < (3/7) > >>

me_7834539:
had the idea of googling for "paragraph sorting".
that has yielded these:
http://www.kahrel.plus.com/indesign/sort.html
http://www.linuxmisc.com/12-unix-shell/b7ccbdb46ef0b9ce.htm
http://backreference.org/2010/08/07/sorting-by-paragraph/

in general, much of this seems to come close...

just as a side note, I'd spend 30-50 USD on a solution...

skwire:
Yes, I am actually using AHK for very simple tasks.-me_7834539 (July 01, 2012, 06:31 PM)
--- End quote ---

Good, I was just making sure before posting a simple script that should accomplish what you want.  I'd normally just paste the script into a codebox right into this post but the code uses a special character that our forum keeps converting erroneously.  Grab the actual code from this link:

http://skwire.dcmembers.com/apps/snacks/cat-parser.ahk

It's just a simple hotkey script so you can merge it into your own scripts or save it out as a stand-alone script.  Once you have it how you like, copy your category text to the clipboard, run the hotkey (default Win+1, or however you incorporate it), and the text should be sorted and placed back on your clipboard.  Let us know how it goes.  Thanks.

MilesAhead:
Another approach may be using a pattern matching language/program. One that's pretty easy to pick up is awk/nawk/gawk .. you can find various free implementations of awk for Windows. In a nutshell it operates on a line of text at a time. When you encounter a pattern, such as some particular thing found in the line like a Tab, colon, substring or whatever, you can set a variable to indicate doing some particular action until the state changes. For example if you find a start tag, then do such and such with the following lines of text until some terminating condition(an empty line for example) is encountered.

It's so long since I used it I totally forget the syntax.  But it's really designed for sifting through text input, rearranging or skipping certain portions, and then writing the output.

Plus you can find a ton of "awk one liners" on the web.  There have to be zillions of canned scripts for awk out there for free.

http://www.pement.org/awk/awk1line.txt

me_7834539:
milesahead, thanks for pointing to awk!

however, skwire's quick ahk script actually works, that's so great, thank you, thank you! (you've got email from paypal, skwire).

I would never have thought that the script would be soo short!

I still have some questions / remarks:

- the script seemed to work perfectly, except for the very first item. the very first item always stayed on top (like this: dfbaacbc -> daabbccf).

- for your information, win-1 is a shortcut that by default is registered by windows itself, to switch to the first taskbar application tab. I had to change it (e.g. to win-i).

- I have not yet thoroughly tested the script, but so far it seems to work very nicely. I did a test if any characters (or tabstops) are lost (German keyboard, all keys incl. using modifiers shift and alt-gr), but everything seemed fine.

me_7834539:
oh... and would it be difficult to add to the script that blank lines be removed after the sorting?  :-[ :Thmbsup:

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version