• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sort lines in TextWrangler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

References: 
 >sort lines in TextWrangler (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: sort lines in TextWrangler
  • Next by Date: Re: Out of Control Aliases?
  • Previous by thread: Re: sort lines in TextWrangler
  • Next by thread: Re: sort lines in TextWrangler
  • Index(es):
    • Date
    • Thread