i have 10000 ++ of numbers with some numbers are duplicate inside...but,they are not sorted in any order (neither ascending nor descending)
e.g. num1 = {100,1234,4566,66,100,1,4566,1234,9999 ......}
i was required to remove those duplicate numbers without moving the sequence of any number, which the result should be :-
num1 = {100,1234,4566,66,1,9999 ........}
so, what i do is :
var num1,num2 :tstringlist;
for i:=0 to num1.count - 1 do begin
if num2.indexof(num1.strings[i])<0 then begin
num2.add(num1.strings[i]);
end;
result = num2.text;
but the problem is, it is running very slow, it need about 40++ second to finish 10000 ++ numbers .....
anotherissue is my total numbers is always changing .....sometimes, i have total 10 numbers, while sometimes might be 10000++ numbers ....
any idea ?
thanks
by: Ivanov_GPosted on 2004-09-24 at 04:59:32ID: 12141858
use TStringList.CustomSort to make your own sorting routine, because comparing numbers as string is not very accurate...