created sorting algorithm