Sorting the Table.DefaultView

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I noticed that strings don't sort correctly when they contain numbers.
For example:
Series: 0
Series: 100
Series: 101
Series: 101
Series: 102
Series: 11
Series: 110
Series: 112
Series: 113
Series: 128
Series: 13
Series: 130

Is there anyway to provide a custom sort? I believe string.Compare() does a
proper comparison.

Thanks,
Joe
 
It looks correct to me. If you type a column as string, this is what you're
supposed to get.
In this case I pad the numbers with leading zeroes.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
 
I would add another column (in-memory) to source table which would contain
numbers as numbers and would sort on this column.
 
In addition to Bill,

Completely correct Sort Sequence for a String, you won't get it in another
way than by first converting it to a numeric format.

You probably want
000
100
101

etc, but than you should use it that way.

Cor
 
Back
Top