Board index » delphi » TStringGrid.Sort (Lexicographic inconsistency Win 3.1 v Win 95)

TStringGrid.Sort (Lexicographic inconsistency Win 3.1 v Win 95)

Here's a strange one.

Using Delphi v1.02:

        Ingrid : TStringGrid;

        Ingrid.Add('0.2');
        Ingrid.Add('-0.1');
        Ingrid.Add('0.1');

        Ingrid.Sort;

        Ingrid.SaveToFile('ingrid.txt');

A program containing this fragment was run on four separate machines, two under Windows 3.1 and two under
Windows 95.

The same .EXE file (compiled under Windows 3.1) was used in each case.

On the Windows 3.1 machines, the sorted string list was:

-0.1
0.1
0.2

Yet on the Windows 95 machines it was:

0.1
0.2
-0.1

Recompiling the program under Windows 95 had no effect.

Both Win3.1 machines had country.sys for the UK.
Both Win95 machine had regional settings set for the UK.

Curious huh?

Andy Coshan

 

Re:TStringGrid.Sort (Lexicographic inconsistency Win 3.1 v Win 95)


Sorry, for TStringGrid read TStringList throughout!

Andy Coshan

Quote
Andy Coshan wrote:

> Here's a strange one.

> Using Delphi v1.02:

>         Ingrid : TStringGrid;

>         Ingrid.Add('0.2');
>         Ingrid.Add('-0.1');
>         Ingrid.Add('0.1');

>         Ingrid.Sort;

>         Ingrid.SaveToFile('ingrid.txt');

> A program containing this fragment was run on four separate machines, two under Windows 3.1 and two under
> Windows 95.

> The same .EXE file (compiled under Windows 3.1) was used in each case.

> On the Windows 3.1 machines, the sorted string list was:

> -0.1
> 0.1
> 0.2

> Yet on the Windows 95 machines it was:

> 0.1
> 0.2
> -0.1

> Recompiling the program under Windows 95 had no effect.

> Both Win3.1 machines had country.sys for the UK.
> Both Win95 machine had regional settings set for the UK.

> Curious huh?

> Andy Coshan

Re:TStringGrid.Sort (Lexicographic inconsistency Win 3.1 v Win 95)


Andy Coshan / Linda O'Connell <c...@tcp.co.uk> wrote:

Quote
>Sorry, for TStringGrid read TStringList throughout!
>Andy Coshan
>Andy Coshan wrote:

>> Here's a strange one.

>> Using Delphi v1.02:

>>         Ingrid : TStringGrid;

I don't know how you could have avoided bombing without it, but
where is Ingrid created?
           Ingrid := TStringList.Create; {List vs Grid per above }

Quote
>>         Ingrid.Add('0.2');
>>         Ingrid.Add('-0.1');
>>         Ingrid.Add('0.1');

>>         Ingrid.Sort;

>>         Ingrid.SaveToFile('ingrid.txt');

>> A program containing this fragment was run on four separate machines, two under Windows 3.1 and two under
>> Windows 95.

>> The same .EXE file (compiled under Windows 3.1) was used in each case.

>> On the Windows 3.1 machines, the sorted string list was:

>> -0.1
>> 0.1
>> 0.2

>> Yet on the Windows 95 machines it was:

>> 0.1
>> 0.2
>> -0.1

>> Recompiling the program under Windows 95 had no effect.

>> Both Win3.1 machines had country.sys for the UK.
>> Both Win95 machine had regional settings set for the UK.

>> Curious huh?

>> Andy Coshan

Here's an experiment on NT3.51 D2:
-------------------------------------------------------------
program ingridt;
{$APPTYPE CONSOLE}
uses Classes;
var
  i:integer;
  Ingrid : TStringList;
procedure Showit(const when:string);
begin
  Writeln(when);
  with Ingrid do begin
    for i:= 0 to count-1 do begin
      Writeln(i:3,': ',Strings[i]);
    end;
  end;
  Writeln('Ingrid.sorted = ',Ingrid.Sorted);
  Writeln;
end;
begin
    Ingrid := TStringList.Create;
    Ingrid.Clear;
    Ingrid.Add('0.2');
    Ingrid.Add('-0.1');
    Ingrid.Add('0.1');
    Ingrid.Add('+');
    Ingrid.Add('-');
    Ingrid.Add('0');
    Ingrid.Add('1');
    Ingrid.Add('2');
    Showit('--------------------<initially>');

    Ingrid.Sort;{}
    Showit('--------------------<after Ingrid.Sort>');

    Ingrid.SaveToFile('ingrid.txt');
    Writeln;
    Write('---------------------<Hit Enter to exit: ');
    readln;
end.
-------------------------------------------------------------
The output was:
====
--------------------<initially>
  0: 0.2
  1: -0.1
  2: 0.1
  3: +
  4: -
  5: 0
  6: 1
  7: 2
Ingrid.sorted = FALSE

--------------------<after Ingrid.Sort>
  0: -
  1: +
  2: 0
  3: 0.1
  4: -0.1
  5: 0.2
  6: 1
  7: 2
Ingrid.sorted = FALSE

---------------------<Hit Enter to exit:
====
And Ingrid.txt was
====
-
+
0
0.1
-0.1
0.2
1
2
====

Regards,
Bengt Richter

Re:TStringGrid.Sort (Lexicographic inconsistency Win 3.1 v Win 95)


Bengt,

Thanks very much for the NT info.

Quote
> Bengt Ricther wrote:

> I don't know how you could have avoided bombing without it, but
> where is Ingrid created?

You are absolutely correct.  I cited the example from (my) memory rather than verbatim.

I'll let you (and the newsgroup) know if I come to any conclusions.

Regards,

Andy Coshan

Other Threads