I have following C# code compiled as Sort.exe:
using System;
using System.Collections.Generic;
class Test
{
public static int Main(string[] args)
{
string text = null;
List<string> lines = new List<string>();
while((text = Console.In.ReadLine()) != null)
{
lines.Add(text);
}
lines.Sort();
foreach(var line in lines)
Console.WriteLine(line);
return 0;
}
}
I have a file input.txt which has following 5 lines as its content:
x000000000000000000093.000000000
x000000000000000000037.000000000
x000000000000000100000.000000000
x000000000000000000538.000000000
x-00000000000000000020.000000000
Now if I run it on command prompt following is the output:
C:\Users\girijesh\AppData\Local\Temp>sort < input.txt
x000000000000000000037.000000000
x000000000000000000093.000000000
x-00000000000000000020.000000000
x000000000000000000538.000000000
x000000000000000100000.000000000
I am not able to understand what kind of string sorting it is where string starting with x-(3rd line in output) comes in middle of strings starting with x0. Either 3rd line should have been at the top or at the bottom. Excel is also showing the same behaviour.