advertisement

Find Code  Advanced Search   

Free Newsletters:   
browse free vb code
Submit Code
ASP,  HTML, and XML
Database
Dates  and Math
Files  and Directories
Forms  and Controls
Lists,  Collections, and Arrays
Miscellaneous
Multimedia/Games
Office/VBA
Network/Internet
Registry
Screen/Graphics
String  Manipulation
System/API
Windows  2000/XP
VB.NET/ASP.NET



advertisement
String Sort Routines: Quick, Merge, Selection, and Insert Sort

Author: Phil Fresle
Category: Lists, Collections, and Arrays
Type: Modules
Difficulty: Intermediate

Version Compatibility:  Visual Basic 5   Visual Basic 6

More information: Generic string sort routines. I prefer to use the 'non-pure' Quick Sort unless you have a good reason to choose another routine.

Here are the routines in order of efficiency.

  • Quick Sort: Fast for large arrays - delegates to insert sort when called with a small array and to sort small chunks of the large array. This 'non-pure' quick sort is therefore quicker by not recursing for small chunks where a simple brute-force iteration is quicker.
  • Merge Sort: Fast for large arrays - larger memory footprint than QuickSort. Delegates to insert sort for small arrays.
  • Insert Sort: Fast for small arrays (say less than 60 values)
  • Selection Sort: Fast for small arrays (say less than 60 values)
NOTE: Due to the recursive nature of Quick and Merge sort they are not very efficient for small arrays which is why the routines delegate to a more brute force insert sort for small arrays.

This code has been viewed 107091 times.

Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

code/stringsort.zip

Sponsored Links