Sorting a hash

[email protected] (Iain Adams)
Newsgroups perl.beginners
Organization http://groups.google.com
Message-ID <c456500e-6193-4b82-a4c0-01c0b41b85f9@s50g2000hsb.googlegroups.com>
Hello,

I am trying to sort a hash of hashes.

My code looks like this:

 foreach $cnt (sort keys %{ $relations{ $uid }{ "instances" } }){
           print OUT "$cnt 1, ";
}

This is returning the correct part of the hash of hashes. However it
is not being sorted correctly. All the instances keys are integers
however they are not being sorted smallest to highest. Instead they
are sorted as if the first digit was the first level qualifier.

An example is:

 100 1, 120 1, 121 1, 122 1, 123 1, 124 1, 125 1, 126 1, 127 1, 132 1,
133 1, 134 1, 135 1, 136 1, 137 1, 138 1, 139 1, 221 1, 222 1, 223 1,
224 1, 225 1, 226 1, 227 1, 228 1, 235 1, 236 1, 237 1, 238 1, 239 1,
240 1, 241 1, 242 1, 323 1, 324 1, 325 1, 326 1, 327 1, 328 1, 329 1,
330 1, 50 1, 51 1, 52 1, 53 1, 54 1, 55 1, 56 1, 57 1, 93 1, 94 1, 95
1, 96 1, 97 1, 98 1, 99 1,

Instead they should start at 50 and range to 330.

Does anyone know why this isn't working and how I can resolve the
problem
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.