You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Trainee-cpp-sort is an imitation of the satandard sort command. I recommend to use this only for test and learning purposes. I developed this sort program so that I can gradually learn to use C ++.
trainee-cpp-sort is a program that has been developed from the beginning and should be an imitation of the standard sortcommand. It was only developed for learning and testing purposes, so I cannot guarantee that it will work perfectly witha real complicated program.
quick sort and merge sort algorithm have also been added to the program, so that with various sort options you have ampleopportunities to simplify your work.
To learn more about what they mean and what they are for, see the bunch of sort options below.
Parameters
short Options
long Options
Usage
-b
--ignore-leading-blanks
Ignore leading blanks.
-f
--ignore-case
Ignore case e.g (uppercase or lowercase) this would be ignored.
-n
--numeric-sort
Numeric sort from the lowest the highest.
-o
--output[ARG required]
Write result in FILE instead of standard output.
-r
--reverse
Reverse the result of sorting.
-R
--random-sort
Sort the keys using a random hash.
-u
--unique
Only output the first of several matches.
-q
--quick-sort
Use quick sort Algorithm.
-m
--merge-sort
Use merge sort Algorithm.
-h
--help
Display this help and exit the Program.
Examples of sort commands..
First of all we have to compile our code and this is done by doing the command as follows./build.sh. This will compile and build your code.If./build.sh doesn't work for you, you can trychmod +x build.sh and it should work now.And the compiled code is saved in thecpp-sort file asmachine code.
Now we can e.g. execute this command to sort the contents of thein.txt filenumeric-sort.content ofin.txt file:
496151031287
The output looks like this, if you run this command./cpp-sort -n in.txt OR./cpp-sort -n < in.txt.
346789101215
if you would like to sort with quick sort or merge sort you only have to change a little bit when executingthe commands as follows./cpp-sort -q -n in.txt OR./cpp-sort --quick-sort -n < in.txt
And we do the same with merge sort./cpp-sort -m -n in.txt OR./cpp-sort --merge-sort -n < in.txt.They all work like clockwork.
And if you want to store the sorted values in a new file, you only have to do as follows..
I hope you have as much fun with it as I have when coding and would be very happy if you would develop the programfurther or if you could give me suggestions how I can do it even better.
Your are always welcome to contribute in this repository
Thank you 👍
About
Trainee-cpp-sort is an imitation of the satandard sort command. I recommend to use this only for test and learning purposes. I developed this sort program so that I can gradually learn to use C ++.