I created this little piece of software to support a presentation about sorting algorithms for school.
It’s basicly a tech-demo of how fast two different algorithm of which one is a little “smarter” work in comparison. It uses the default merge sort algorithm as well as the natural merge sort algorithm with enhanced performance. There is also a public java-implementation of this algorithm for sorting arraylists of any type that can be found here.
Launch the application with the shipped .bat – file.
There are the following commands available:
info : toggles printing of more precise steps of algorithm. Disable for better performance
generate <filepath> <lines> <rmin> <rmax> : generates a new demo-file with random numbers which can be used to test sorting of large amounts of data. <filepath> is relative to the .jar's location. <lines> sets how many lines (numbers) the file contains. <rmin> and <rmax> define the minimum and maximum value for the random-number-generator.
sortfile [normal:natural] <inputpath> <outputpath> : sorts a previously generated file where <inputpath> defines the unsorted file's source and <outputpath> will be the finished sorted file. You can choose wether the normal or enhanced (natural) algorithm is used with the second argument.
sortlist [normal:natural] <integerlist> : sorts a list of manually typed numbers. Choose a mode as second argument and insert the list of numbers (seperated by ",").
You should avoid using too large amounts of data (like over 1000k lines) because that will most likely cause a buffer overflow. When writing the file it’s not the problem, but when sorting it the algorithm needs to load all numbers at once.
You need Java 1.7+ and the JDK installed in order to run this.
Download .jar and launch-batch-file here.