home *** CD-ROM | disk | FTP | other *** search
- today was 3.10.1993.
-
- This is my first public appearance, and I don't think it's the last.
- I hope someone would find this program useable.
- If you call program with option everything would be obviously.
-
- Part of this text you can find in source file.
-
- This program is based on shellsort, best known sorting algorithm as I know.
- If anybody knows better algorithm, let me know.
- Here is source in C:
-
- void shellsort(char *p[],short n)
- /* p is array of pointers to char strings(ending with '\0')
- n is no. of elements (lines) */
- { short range,i,j;
- char *aid;
- for(range=n/2;range>0;range/=2)
- { for(i=range;i<n;i++)
- for(j=i-range;j>=0 && strcmp(p[j],p[j+range])>0;j-=range)
- { aid=p[j];
- p[j]=p[j+range];
- p[j+range]=aid;
- }
- }
- }
- Meaning is that you divide field of strings on two, and compare two elements
- with first range n/2, and if you find some to change do it and look behind
- is there maybe another element to change. When i and j loops finish, make
- new range, now it is n/4 and so on. Mathematicaly i don't know how many
- passes through array has to be done but it is fastest as I know.
-
- First I make necessary house works and then read input file. I read it twice.
- Why? First, to read no. of lines and second time to read lengths of lines
- because then I can make proper allocations (this reads depend on option).
- Then I make sort and finally write to output file and deallocate memory.
- I know there is double use of code, but I want it to be fastest and instructions
- in all loops are one word long. I tried as much as I could to do work in regs
- also to be faster. It is up to you to judge.
-
- Personally, I tested program a lot of times with different files. Biggest file
- as I remember, was about 500k and sort was done good. Sometimes there can be
- found 1 trash byte at the end of the file. Sort is case sensitive and in my
- next versions I will put case insensitive sort, but it slows down sorting
- and I'll try to make it as fast as I can. If you know good algorithm and if
- that wouldn't be hard for you, contact me.
- Finally, speed.
- This program is 10 (TEN) times faster then sort you have in Workbench.
- This is on A1200. I have it. I didn't test it on A500. You may try.
- So, use it if you like it.
- This program is public domain, of course.
- I would like you people to contact me to exchange knowlege. Come on!
- I am mostly interested in SYSTEM programming.
- Don't be lazy.
-
- My address:
-
- Herendic Drazen
- Ul. 26. lipanj 9
- 43240 Cazma
- CROATIA
-
-
- You can send E-mail on my friend's address:
-
- korzi@branka.zems.etf.hr
-
- If you send there, note for Drazen Herendic.
-
-