I want to arrange my records date wise from earlier to current within the category

I want to arrange my records date wise from earlier to current within the category

 

Query which i used in my code-

Set @a:=-1;
set @b:=0;
SELECT m.allocationID,mt.CatId,mt.CatSName,r.officerName,r.desgName,r.grade,r.cellNo,IF(mt.CatSName='E',@a:=@a+2,IF(mt.CatSName='D',0,@b:=@b+2)) as rwid
FROM msttransaction m,msttemp mt,regusers r WHERE (m.isPending='Y' AND m.statusR='Approve' AND m.iscancelled='No' AND m.allocationID IN ( SELECT mt.AllocationId FROM msttemp WHERE mt.quarterId='082505012')and SUBSTRING(m.AllocationId,1,11)=r.pfNpsNo)  OR (m.isPending='N' AND m.type='Transit' AND m.statusR='Approve' AND m.iscancelled='No' AND m.allocationID IN ( SELECT mt.AllocationId FROM msttemp WHERE mt.quarterId='082505012')and SUBSTRING(m.AllocationId,1,11)=r.pfNpsNo) ORDER BY rwid,SUBSTRING(m.AllocationId,14) 

But i want my result as 

i want to arrange my ouput according to datewise ie SUBSTRING(m.AllocationId, -14) in my case within the category that means for D category which comes first comes first within the category hope you guys understand,thanks in advance