Typical sort alorithm