<?xml version="1.0" encoding="windows-1252"?>
<node id="75511" title="Hash sort again!!" created="2001-04-25 16:06:56" updated="2005-08-13 02:42:58">
<type id="115">
perlquestion</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
I realise I am stupid and shouldn't have been let loose on PERL in a million years but I need help!!
Can anyone PLEASE help me with a hash sorting problem I am having??
I will be eternally grateful!!!!!!!

I have successfully created a hash containing all the keys and values I want but wish to merely sort the keys into ascending numerical order. Am I doing something wrong with my hash assignment? I cannot quite see why it won't work
See excerpt below
&lt;BR&gt;
&lt;CODE&gt;
foreach $sentence(@sentences) { &lt;BR&gt;
	$total_sentence +=1; &lt;BR&gt;
	@words = split(/[^\w'a-zA-Z0-9_'-?]+/,$sentence); &lt;BR&gt;
	$Counter =0; &lt;BR&gt;
foreach $word(@words){ &lt;BR&gt;
	$Counter+=1; &lt;BR&gt;
	} &lt;BR&gt;
$sentence_count{($Counter)}=$sentence_count{($Counter)}+1;&lt;BR&gt;							
}
&lt;BR&gt;
sort {$a&lt;=&gt;$b} (keys (%sentence_count)); &lt;BR&gt;
print ("\nThere are a total of $total_sentence sentences in this text\n"); &lt;BR&gt;
while (($sentence_count,$word_count) = each(%sentence_count)) {  &lt;BR&gt;
	print ("\nThere are $sentence_count sentences of $word_count words\n"); &lt;BR&gt;
} &lt;BR&gt;

&lt;/CODE&gt;</field>
<field name="reputation">
-2</field>
</data>
</node>
