http://www.perlmonks.org?node_id=341556

Murcia has asked for the wisdom of the Perl Monks concerning the following question:

Hi Conferes,

I have a large file with identifer in each row of this file. Equal ids are unevenly spreaded within the file. I need the data after the id, so I have to collect all data for the same id, grepping for each id the whole file. is takes a long time!
My idea is first to sort the file by id, so that I can find the first position in the file with a id, reading lines till the id changes.

eg: 
10 data1
12 data2
13 data4
1  data5
10 data6
12 data7
2  data8
10 data11

sorted: 
1 data5
10 data1 # beginn id 10
10 data11
10 data6 #end id 10
12 data2
12 data7
13 data4

should I load the file in an array, sort and print it? Or are there better ways (the file has 183M)?

Thanks and GOD saves PERL!

Guido