in reply to Date Array Convolution

Do the Schwartzian boogy! or here is a typical multifield sort.
#!/usr/bin/perl -w use strict; my @data; while (<DATA>){ my @dataline = split (/\s+/,$_); print "@dataline\n"; push(@data,\@dataline) } print "\n@data\n\n"; &printarray(\@data); print "\n"; my @data_sorted_by_four_fields = sort { $a->[2] <=> $b->[2] || $a->[0] <=> $b->[0] || $a->[4] <=> $b->[4] || $a->[1] cmp $b->[1] } @data; &printarray( \@data_sorted_by_four_fields ); print "\n"; ###########################################3 # Print the contents of the array sub printarray { my $aref=shift; foreach my $record (@$aref) { for my $i (0..4) { print $record->[$i] . " "; } print "\n"; } } ############################################# __DATA__ 1040564312 z 89 Out 4194077715 1040564322 w 90 Out 4194081727 1040564335 x 94 IN 4194085256 1040564335 y 94 Out 4194085196 1040564312 z 89 In 258381720 1040564322 z 90 In 258385268

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Date Array Convolution
by alanonymous (Sexton) on Nov 03, 2011 at 20:18 UTC
    I think I have the multi-dimensional sorting piece figured out (just sorting by start times) with:
    @combined = sort {$a->[0] <=> $b->[0]} (@listone,@listtwo);
    What I really need help with is the piece that covers those two difficulties I mentioned in the original post. Something like:
    @combined = sort {$a->[0] <=> $b->[0]} (@listone,@listtwo); foreach (@combined) { #check for overlapping times and make sure the smallest V time is + listed during the overlap #XXXXXXX #break the timespans apart if it covers the crossing of a new day #XXXXXXX }