neither great code nor a great sorting algo