finish sort algorithm