[H-GEN] Mergesort

Byron Ellacott bje at apnic.net
Mon Jul 31 00:34:36 EDT 2000


[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

On Mon, 31 Jul 2000, Martin Pool wrote:

> import fileinput
> a=[]				# an empty list
> for line in fileinput.input():
>   a.append(int(line))
> a.sort()
> for value in a:
>   print value


#!/usr/bin/perl -w

$/ = undef;
my $array = <STDIN>;
print join("\n", sort {$a <=> $b}  split(/\s/, $array));


-- 
bje


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list