• 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' command-alternative?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'sort' command-alternative?


  • Subject: Re: 'sort' command-alternative?
  • From: Rob Jorgensen <email@hidden>
  • Date: Thu, 3 Oct 2002 19:30:58 -0400

At 11:22 PM +0100 10/3/02, John Delacour wrote:
At 2:31 pm -0400 3/10/02, Rips Ethan J wrote:

b. if there's an alternative, such as a sort command in a shell script that
can be called by Applescript.


Here's a script that returns a sorted list of the the names of running processes. You can adapt it to any use. You can also sort by number with a slight addition.

tell app "Finder" to set ls to name of processes
set AppleScript's text item delimiters to {return}
set ls to ls as string -- turn the list into paragraphs
set AppleScript's text item delimiters to {""}
do shell script "perl -e '
$return = qq(\\015) ;
$list = qq(" & ls & ") ;
@array = split /$return/, $list;
for (sort @array) { print qq($_$return) } '"
paragraphs of result

When I run this, everything is sorted alphabetically except the last item: loginwindow

It follows Virex 7.1. Is that the expected behavior?

--

Rob Jorgensen
Ohio, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: 'sort' command-alternative?
      • From: John Delacour <email@hidden>
References: 
 >'sort' command-alternative? (From: "Rips Ethan J" <email@hidden>)
 >Re: 'sort' command-alternative? (From: John Delacour <email@hidden>)

  • Prev by Date: What version of Entourage is it?
  • Next by Date: Re: 'sort' command-alternative?
  • Previous by thread: Re: 'sort' command-alternative?
  • Next by thread: Re: 'sort' command-alternative?
  • Index(es):
    • Date
    • Thread