TStringList *list = new TStringList();
// 原始內容 {"22", "211", "222", "33"};
list->Sort();
// Sort() 後的結果, 是依序比較字串開頭的大小 {211, 22, 222, 33};
// 想按數字大小排序 {22, 33, 211, 222};, 需用 CustomSort()
list->CustomSort(compare);
// 並自訂 compare function
int __fastcall compare(TStringList* List, int Index1, int Index2)
{
if (StrToInt(List->Strings[Index1]) > StrToInt(List->Strings[Index2]))
return 1;
else if (StrToInt(List->Strings[Index1]) == StrToInt(List->Strings[Index2]))
return 0;
else
return -1;
}