in reply to how to sort string in perl
This should provide you a couple hints:
$ cat bozosort.pl #!/usr/bin/perl use strict; use warnings; my @list = (1, 2, 3, 9, 6, 4, 5, 7, 0); while (@list) { my $idx = int rand @list; next if grep { $list[$idx] > $_ } @list; say splice @list, $idx, 1; }
On my machine, this produces:
$ perl bozosort.pl 0 1 2 3 4 5 6 7 9
You'll want to make appropriate changes to improve performance, use files, etc.
Update: Hung a lantern on it.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to sort string in perl
by Anonymous Monk on Dec 05, 2012 at 17:44 UTC |
In Section
Seekers of Perl Wisdom