Thread Zeilen sortieren anhand erstem Wert der Zeile (8 answers)
Opened by cohama at 2014-04-02 10:38

GwenDragon
 2014-04-02 11:58
#174587 #174587
User since
2005-01-17
14483 articles
Admin1
[Homepage]
user image
Schau mal:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict; use warnings;

my @zeilen = <DATA>;

my @sortiert = 
  map { 
        $_->[0] 
  }
  sort { 
        $a->[1] <=> $b->[1] 
  }
  map { 
        [ $_, /^(\d+)/ ] 
  }
  @zeilen;
                
print for @sortiert;

=pod

ergibt als Ausgabe:

7744 OUT 2014-04-01 00:03:00 75 3375504915 X national 3413552992 
7744 OUT 2014-04-01 00:05:00 15 3375504915 X international 3413552992
7749 OUT 2014-03-31 23:28:00 2235 3375504090 X national 2513238104 
9041 OUT 2014-03-31 23:33:00 2323 33785239951 X national 3099196476 
201749 OUT 2014-04-01 00:00:00 30 38362758258 X unkown 2758259 
202261 OUT 2014-03-31 23:45:00 1027 33764785002 X national 303945793 
204079 OUT 2014-04-01 00:13:00 0 33678999952 X international 22090506432 
204079 OUT 2014-04-01 00:13:00 0 33678999952 X international 22090506432 
204079 OUT 2014-04-01 00:14:00 37 33678999952 X international 35228489070

=cut

__DATA__
201749 OUT 2014-04-01 00:00:00 30 38362758258 X unkown 2758259 
202261 OUT 2014-03-31 23:45:00 1027 33764785002 X national 303945793 
7744 OUT 2014-04-01 00:03:00 75 3375504915 X national 3413552992 
7749 OUT 2014-03-31 23:28:00 2235 3375504090 X national 2513238104 
7744 OUT 2014-04-01 00:05:00 15 3375504915 X international 3413552992
9041 OUT 2014-03-31 23:33:00 2323 33785239951 X national 3099196476 
204079 OUT 2014-04-01 00:13:00 0 33678999952 X international 22090506432 
204079 OUT 2014-04-01 00:13:00 0 33678999952 X international 22090506432 
204079 OUT 2014-04-01 00:14:00 37 33678999952 X international 35228489070
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Zeilen sortieren anhand erstem Wert der Zeile