in reply to sort large file

The best solution is dependant of a couple of parameters:
- How often do you run that program (1/day, 1/minute ?)
- How static is the data (do you get new entries every time you run your program?)
- Are you looking for 1 key at a time (in a online app) or do you anyway scan through all the keys in 1 run?

Now as we know you have to read all keys anyway just use a hash with your keys and "feed" an array with your data:
push (@{$myhash{$id}}, "$data");

I can resist anything but temptation.