facted out sort method in Directory class.