QuickSort for InstallShield

Version 1.0 release, March 1999


This InstallShield extension uses the QuickSort algorithm to sort data.
There are two files that you need:

I have create three functions that you can call to sort you data:
Function Description
QuickSortNumList Sort a list of numbers in accending order
QuickSortString Sort a string in accending order
QuickSortStrList Sort a list of strings in accending order


QuickSortNumList(BYREF LIST)

This function takes one parameter, the numeric list that you want to sort. It will use the QuickSort algorithm to sort the list in accending order. The following code sample shows how to use this function.

QuickSortNumList Example

function TestQuickSortNumList()
	LIST	lstTest;
begin
	// Test the QuickSort of a NUMBER LIST
	lstTest = ListCreate(NUMBERLIST);
	ListAddItem(lstTest, 323, AFTER);
	ListAddItem(lstTest, 3, AFTER);
	ListAddItem(lstTest, 43, AFTER);
	ListAddItem(lstTest, 33, AFTER);
	ListAddItem(lstTest, 1, AFTER);
	ListAddItem(lstTest, 63, AFTER);
	SdShowInfoList("Before", "List Before Quick Sort", lstTest);
	QuickSortNumList(lstTest);
	SdShowInfoList("After", "List After Quick Sort", lstTest);
	ListDestroy(lstTest);
end;


QuickSortString (BYREF STRING, BOOL)

This function takes two parameters, the first is the string that you want to sort. It will use the QuickSort algorithm to sort the string in accending order. The second is a boolean value that tells the algorithm if you want to be case senative. This function is just a special implemation of the QuickSortStrList() function. It breaks the string into a list, sort it and then recreate the string from the sorted list.
The following code sample shows how to use this function.

QuickSortStrList Example

function TestQuickSortStrList()
	STRING	szTest;
begin
	// Test the QuickSort of a STRING
	szTest  = "kjslkjdlASJDLSAJLdsldij";
	QuickSortString(szTest, TRUE);
	SprintfBox(INFORMATION, "", "String after case-sensitive on -- %s", szTest);
end;


QuickSortStrList(BYREF LIST, BOOL)

This function takes two parameters, the first is the string list that you want to sort. It will use the QuickSort algorithm to sort the list in accending order. The second is a boolean value that tells the algorithm if you want to be case senative.
The following code sample shows how to use this function.

QuickSortStrList Example

function TestQuickSortStrList()
	LIST	lstTest;
begin
	lstTest = ListCreate(STRINGLIST);
	ListReadFromFile (lstTest, "c:\\autoexec.bat");
	SdShowInfoList("Before", "List Before Quick Sort", lstTest);
	QuickSortStrList(lstTest, FALSE); // We are not interested in case
	SdShowInfoList("After", "List After Quick Sort", lstTest);
end;


If you have any question or comment please feel free to contact me.

Author: Martin Finnerty
e-mail:
NOSPAM_Martin_Finnerty@hotmail.com