added sort function