Thread Sort() (10 answers)
Opened by taikahn22a at 2008-05-08 22:02

FIFO
 2008-05-08 23:18
#109474 #109474
User since
2005-06-01
469 Artikel
BenutzerIn

user image
Code (perl): (dl )
1
2
3
4
5
6
use warnings;
use strict;

my @array = (1..20);
my @array3 = sort { $a <=> $b } map { $_ % 5 } @array;
print join(', ', @array3);


Ausgabe: 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"

View full thread Sort()