added sorting algorithm