int iEnd = ListBox1->Items->Count - 1;
AnsiString str1,str2,temp;
while (x)
{
x = false;
for (int i = 0; i <iEnd ; i++)
{
str1 = ListBox1->Items->Strings[i];
str2 = ListBox1->Items->Strings[i+1];
str1 = str1.SubString(str1.AnsiPos("#")+1,100);
str2 = str2.SubString(str2.AnsiPos("#")+1,100);
if (str1.ToInt() < str2.ToInt())
{
temp = ListBox1->Items->Strings[i+1];
ListBox1->Items->Strings[i+1] = ListBox1->Items->Strings[i];
ListBox1->Items->Strings[i] = temp;
}
}
iEnd--;
}
But it only sorts the first 2 people only Original list
Pretorius Correlie#1
Lemmer Summayah#16
Erasmus Henriette Gertrud#1
Januarie Lynn Melissa#26
Swartz Tamaran#20
Moore Dane#14
Schlumf Barry#17
Greyling Kylie#22
Jaftha Eden#17
Majali Tamsyn#16
Appolis Darion#18
Draai Oreal Isabel#17
Lombard Shelby#21
Higgins Lee-Ann#19
Mayola Ndiphiwe#22
Layman Lucille#13
Navsaria Sachen#28
Govender Trevlin#20
Smith David#14
Du Buson Gabriela#31
Links Shannon#22
Pow Chong Curt#21
Smith Kyle#19
Thomas Carla#16
Losi Lelethu Siyasanga#23
Fortune Karen#20
Sithonga Siphiwo#21
Mgoqo Neliswa#22
the sorted list
OK, if you're using Emabarcadero c++ builder, there might be another way to solve your problem.
I've never use C++ Builder, but I have used Delphi and Lazarus, and the classes do look very similar to me.
If Builder provides you with the TStringList class and it has a CustomSort method, and TListBox's Items is a TStrings, then you might be able to port this Delphi code to C++