Sorting algorithm based on sleeping