I have a text file with data like:

```
# Pri: Rest, DTG: 20140109183524.013578591, CID: 1004592976
dn: op=applV,uid=2256c1e8-1166-46e4-a3a9-9fbe27694e12,Name=sub,loc=Ph,o=s,o=s.com
action: add
Class: c-subSpecData
Option3: applView
Option2: 3

# Pri: Rest, DTG: 20140109183524.013580787, CID: 1004592977
dn: op=applV,uid=2256c1e8-1166-46e4-a3a9-9fbe27694e12,Name=sub,loc=Ph,o=s,o=s.com
action: add
Class: c-subSpecData
Option3: applView
Option2: 3
Option1:34
Option5:98

```

One Data Unit starts from '#' til the next '#'. Like from the above sample one data unit is:

```
# Pri: Rest, DTG: 20140109183524.013580787, CID: 1004592977
dn: op=applV,uid=2256c1e8-1166-46e4-a3a9-9fbe27694e12,Name=sub,loc=Ph,o=s,o=s.com
action: add
Class: c-subSpecData
Option3: applView
Option2: 3

```

Now I have to sort this data on the basis of DTG. (e.g 20140109183524.013580787 as given in the second data unit). 

The output file would have the same data but sorted on the basis of DTG value (which is actually date and time).

The other data units are unimportant as far as sorting of data is concerned.

The actual input file would contain thousands of such entries. 
What would be the fastest way to achieve a sorted data? Speed is actually important in achieving the required result.