Added sample sorting algorithm