You could use a script, but one relatively easy, albeit slightly
tedious, way is to do this sequence:
Search and replace ^(.*)$ with \1z<BULLET>\1, where <BULLET> is any
character that never appears in your file, Bullet (option-8) is
usually a good choice.
Next search and replace .(x*z<BULLET>) with x\1. Repeat this N times
where N is the length of the longest line. To reduce this, you can
use two replaces:
.....(x*z<BULLET>) with xxxxx\1
and when it runs out
use the first replacement up to four times.
Next, sort the lines. The z before the bullet ensures the sort order
is descending in length
Next, replace .*z<BULLET> with nothing.
As I say, slightly tedius, but easy.
And the alternative of using a script may be better if you are
script-capable, but this would work, and could be easily done as a
text factory (although I notice Text Factory items cannot be option
dragged in the same factory - however you can create a second dummy
text factory, drag that search and replace that needs repeating to
it, and then drag it back N times).
Enjoy,
Peter.
--
Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.stairways.com/>
Some things are fun and some are instructive.
For ASCII text I thought about mentioning a perl filter. You could get the text from BBEdit and read it, line by line into a perl array with a read and push loop
perl's array sorting ability allows you to define your own call back for larger/smaller testing and you could use a one line subroutine like this:
{ len($a) <=> len($b) }
The whole thing would be a dozen lines maximum.
But, . . . . .
Then I though: This is a MacIntish !. He really means to have it all work in a font-aware way that would allow for proportional spacing. "mmm" needs to sort as longer than "iii". I think I could do that with quickdraw calls but I haven't the foggiest idea how it could be accomplished in OS neXt. Given the push to UTF-8 I'm not even sure it would work as text.
--
--> From the U S of A, the only socialist country that refuses to admit it. <--