adds sort functionality that really should have been included in the language