|
The fool asks a silly question:
============
Smart people answer smart questions. :) :)
function Compare (List: TStringList; Index1, Index2: Integer): Integer;
begin
if List [Index1] = '0' then
if List [Index2] <> '0' then
Result: = 1
else
Result: = 0
else
if List [Index2] = '0' then
Result: = -1
else
Result: = CompareText (List [Index1], List [Index2]);
end;
procedure TFormDemo.ButtonDemoClick (Sender: TObject);
var
SL: TStringList;
begin
SL: = TStringList.Create;
SL.Add ('0');
SL.Add ('4');
SL.Add ('1');
SL.Add ('0');
SL.Add ('0');
SL.Add ('5');
SL.Add ('3');
SL.Add ('2');
SL.CustomSort (@Compare);
ListBox.Items: = SL; // Look at the result
end;
//result
======
1
2
3
4
5
0
0
|
|