added sort function - still work in progress