in reply to Search Engine Output needs sorting
Okay, I have solved the frequency sorting by changing the prints to push. Then getting an array and joining the headers and allsentences. Then sorting by length.:
#5# .... push (@allsents, "MATCH #$count $sentmatches[$ +m]") unless $seens{ $sentmatches[$m] }++; $count++; } } push (@sepmatches, @allsents); ##$allmatches[0] is header, [1] is all sentences etc. +EVEN - header, ODD - sent ## Now join headers and sentences (0 and 1 etc.) foreach (@sepmatches) { ##Try Use natatime where n=2 $joinmatches = join ('', @sepmatches); } push (@allmatches, $joinmatches); @sortedallmatches = sort {length $b cmp length $a} @al +lmatches; } } } print @sortedallmatches; }
The messy part (though it's all pretty messy) is that I had to call the @allmatches after the first for loop so it would not print every result every time. Then call @sepmatches after the second for loop
Thanks for the help PM, I hope to join the ranks when I know a little more Perl!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search Engine Output needs sorting
by Anonymous Monk on May 29, 2011 at 08:09 UTC |