added and checked sorting algorithm