SPUG: Sort an array question

Andrew Reid blueovalfun at yahoo.com
Thu Dec 26 17:09:30 CST 2002


Brian, 

Cool, Thanks!  I'll look into this.  I've never used
IPC module before.  Seems like a good place to check.

I didn't do the best job setting this up, I gave this
problem as it was presented to me.  One of the
stipulations as I started working on it at the board
was that everything be sorted in a single array. 
"Without creating a new memory space" is what the guy
said if I remember correctly.  

I'll look at IPC, thanks again.  

--- Brian Hatch <spug at ifokr.org> wrote:
> 
> 
> > While attempting to gain more meaninful
> employment, I
> > happened upon this question from a prospective
> > provider of opportunity.  "Sort an array
> > alphabetically without using the Perl sort
> command." 
> > This was provided by someone not familiar with
> Perl
> > but other languages and all work was shown on a
> white
> > board.  I think I did OK, there were a few holes
> in
> > the code, and I decided to really give it a shot. 
> > This works and is very close to what I provided on
> the
> > spot.
> > 
> > If any of you have some free time and thoughts,
> I'd
> > appreciate them!  Tell me what you think.
> 
> 
> Though you could certainly code up a
> bubble/insertion/quick sort
> or such, how 'bout 
> 
> 
> 	#!/usr/bin/perl -w
> 
> 	use IPC::Open2;
> 	use strict;
> 
> 	my @array1 = qw(e c g h z r t a i h j l p b d r q x
> v a);
> 
> 	open2(*R, *W, "sort") or die "Can't run sort!":
> 	print W join "\n", @array1;
> 	close W;
> 	chomp(@array2 = <R>);
> 
> 	print "Sorted version: @array2";
> 
> 
> After all, TMTOWTDI.
> 
> 
> 
> 
> --
> Brian Hatch                  Each generation has
>    Systems and                it's signaure disease.
>    Security Engineer          The Black Plague.
> http://www.ifokr.org/bri/     Cholera. Ebola. AIDS.
>                               Windows 2000.
> Every message PGP signed
> 

> ATTACHMENT part 2 application/pgp-signature 



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list