SPUG: sorting an array

Kevin Fink kevin at n2h2.com
Mon Jun 19 20:06:44 CDT 2000


On Mon, 19 Jun 2000, Ryan Ames wrote:

> I am kind of a newbie to perl and was wondering if there was a quick way to
> do a sort on an array of long ints.  
> 
> My array would look something like this.
> 
> 	@myArray = (123000, 122956, 239210, 128967, 543902, 209031, 333910);

Sorting by numerical order or something more complicated?  The former is
easy:

@mySortedArray = sort { $a <=> $b } @myArray;

Kevin


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 For Subscriptions, Email to majordomo at pm.org:  ACTION  spug-list  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address





More information about the spug-list mailing list