Finished Rack machine sorting algorithm.