Практически! Спасибо! Ещё бы индексы "sort" меняла
------ С Уважением, Олег Малёваный > >-----Original Message----- > >From: [email protected] [mailto:moscow-pm- > >[email protected]] On Behalf Of Denis Evdokimov > >Sent: Monday, December 07, 2009 4:01 PM > >To: Moscow.pm group > >Subject: Re: [Moscow.pm]Вставка в спиоск в определенное место > > > >Как-то так? > > > >#!/usr/bin/perl > >use strict; > >use warnings; > > > >use Data::Dumper; > > > >my $sort_index2 = 0; > > > >my @a = ( > > { > > name => 'a', > > sort => 0, > > sort_index2 => ++$sort_index2, > > }, > > { > > name => 'b', > > sort => 4, > > sort_index2 => ++$sort_index2, > > }, > > { > > name => 'c', > > sort => 10, > > sort_index2 => ++$sort_index2, > > }, > >); > > > >push @a, > > { > > name => 'd', > > sort => 0, > > sort_index2 => ++$sort_index2, > > }; > > > >print Dumper \...@a; > >@a = sort my_sort @a; > >print Dumper \...@a; > > > > > >sub my_sort > >{ > > my $answer; > > if ( $a->{sort} > $b->{sort} ) > > { > > $answer = 1; > > } > > elsif ( $a->{sort} < $b->{sort} ) > > { > > $answer = -1; > > } > > else > > { > > $answer = 0; > > } > > > > if ( $answer == 0 ) > > { > > if ( $a->{sort_index2} > $b->{sort_index2} ) > > { > > $answer = -1; > > } > > else > > { > > $answer = 1; > > } > > } > >return $answer; > >} > >-- > >Moscow.pm mailing list > >[email protected] | http://moscow.pm.org -- Moscow.pm mailing list [email protected] | http://moscow.pm.org
