trying to figure out how to write a fast sort