in reply to substr sort ??

You would have spotted this error easy if you had used use strict and use warnings.