Posted on 2007-01-09 13:46:54-08 by palyk
sort only first 2 records
I have code like bellov. Problem is that it sorts only first two record. If I use just function slovak sort - for ordering array, everithing works fine. Problem is that I need sort hash, but for this it sort only first 2 records and than function my_cmp returns always 0. I dont know if its problem with perl version(5.8.8 64b) or something else. Thanks
my @array1; use Sort::ArbBiLex( 'slovak_sort', "a A b B ....."); sub my_cmp { return Sort::ArbBiLex::xcmp(\&slovak_sort, @_) }; #sub my_cmp { @_[0] cmp @_[1] }; push @array1,'sipos'; push @array1,'petr'; push @array1,'ruzenka'; push @array1,'zsxs'; push @array1,'mala'; push @array1,'szxsko'; push @array1,'xsxsec'; push @array1,'zuzanka'; push @array1,'xsxsanka'; push @array1,'abeceda'; push @array1,'xsxsva'; @array1 = sort{if(1){print my_cmp($a, $b)."-$a--$b-\n";return my_cmp($a, $b)*1;} } @array1; #@array1 = slovak_sort(@array1); print "<pre>".Dumper([@array1])."</pre>";
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.