Finished up fast using a quickselect algorithm. Just need to comment everything.