At this point I would suggest that you take a step back and consider whether a hash or an array (or, maybe an array of hashes?) might be the best fundamental representation in your program. Because, what you are basically trying to do in this single statement ... what you are probably asking Perl to do ... is to construct and then sort an array on-the-fly. (This will be true if-and-when you get this statement working ...) Well, that's a very expensive thing to do, especially when you don't realize that you're doing it.