Thread Die Reihenfolge meiner Liste ändern! Hilfe!!! (1 answers)
Opened by Pro_Galli at 2007-10-18 15:29

renee
 2007-10-18 16:23
#101023 #101023
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
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
45
46
#!/usr/bin/perl

use strict;
use warnings;

my @array = <DATA>;
my %hash;

# in den Hash überführen
for ( @array ){
    my @info = split /;/, $_;
    push @{ $hash{$info[0]} }, [$_, @info];
}

# neu sortieren
for my $key ( keys %hash ){
    my $sec_index = 0;
    my $sec       = "";
    for ( 0 .. $#{ $hash{$key} } ){
        if( $hash{$key}->[$_]->[2] ne $sec ){
            $sec       = $hash{$key}->[$_]->[2];
            $sec_index = $_;
        }
        if( $hash{$key}->[$_]->[3] eq $key ){
            splice( @{ $hash{$key} },$sec_index, 0 , splice( @{$hash{$key}},$_,1 ) );
        }
    }
}

# Ausgabe
for my $key ( sort keys %hash ){
    print $_->[0] for @{ $hash{$key} };
}

__DATA__
2112;6630325;SolidCAM;66303251_BUCHSE.PRT
2112;6630325;SolidCAM;66303251_BUCHSE_000.PRT
2112;6630325;2112;6630325A-.o
2112;6630325;GEO;6630325-SP1AVO0202112.GEO
2112;6807602;2110;6807602A-.o
2112;6807602;2112;6807602A-.o
2112;6807602;2127;6807602A-.o
2126;6924191;2125;6924191AA.O
2126;6924191;2125;6924191BA.o
2126;6924191;2126;6924191AA.o
2126;6924191;2127;6924191A-.o
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Die Reihenfolge meiner Liste ändern! Hilfe!!!