Scott Logic interview question

what does this pseudocode do? (sorting algorithm) Three-Hat puzzle Mislabeled jars puzzle