Re: sort lines in TextWrangler
Re: sort lines in TextWrangler
- Subject: Re: sort lines in TextWrangler
- From: Shane Stanley <email@hidden>
- Date: Sun, 11 Nov 2012 23:02:43 +1100
On 11/11/2012, at 9:20 PM, koenig.yvan <email@hidden> wrote:
I have a text file with about 90,000 lines so I assumed that it would be a good idea to use TextWrangler to sort the lines.
If you didn't want to use TextWrangler and it's in an applet, you could save it as a Cocoa-AppleScript app and use this:
tell current application's NSString to set theText to stringWithString_(theText) -- make an NSString set theArray to theText's componentsSeparatedByString_(return) -- modify par separator to suit set theArray to theArray's sortedArrayUsingSelector_("localizedCaseInsensitiveCompare:") -- or other sort set sortedText to theArray's componentsJoinedByString_(return) as text
Or use ASObjC Runner:
script sortPars set theText to current application's NSApp's convertedValue() -- retrieve the converting value set theArray to theText's componentsSeparatedByString_(return) -- modify par separator to suit set theArray to theArray's sortedArrayUsingSelector_("localizedCaseInsensitiveCompare:") -- or other sort return theArray's componentsJoinedByString_(return) end script tell application "ASObjC Runner" to set sortedText to run the script {sortPars} converting someText with response |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden