Re: Sorting Datagrid With Hyphen / Dash
From: Chris Mayers (chris_mayersBLUE_at_SUEDEYahoo.Com)
Date: 03/10/05
- Next message: Subba Rao via DotNetMonster.com: "Re: Help needed with DataGrid Client-Side Scripting"
- Previous message: Banda RamaNarsiReddy via .NET 247: "binding Treeview in datagrid(ASP.Net(C#))"
- In reply to: Samuel Kim: "Re: Sorting Datagrid With Hyphen / Dash"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Mar 2005 10:07:38 -0000
Thanks for your answer, I kind of understand what you are saying, but do you
have any code samples that would make it a little clearer?
However, this still does not really explain exactly what is going on with
the sorting at the moment.
ie
30-199
30-299
303-01
303-02
30-399
30-499
Regardless of the ASCII value of the hyphen, this sort order is WRONG, all
the '30-' codes should be together, and all the '303' codes should be
together. This sequence only makes sense if you ignore the hyphen completly,
ie:
30199
30299
30301
30302
30399
30499
Therefore, I draw the conclusion that tha DataGrid treats the hyphen as a
'special' character for the purposes of sorting. I guess this is because if
you were sorting proper words you would want (say) 'co-operative' to be
sorted next to 'cooperative'. But surely this behaviour should be
controllable...?? :-/
ALL I want is a way of getting the DataGrid (or DataView) to sort the data
with a proper ASCII sort, without any 'special casing' being applied to any
of the characters...
Anyone got any suggestions on that??
Cheers,
Chris.
"Samuel Kim" <look341@gmail.com> wrote in message
news:1110325517.500209.265740@o13g2000cwo.googlegroups.com...
> Due to their sequence in the ASCII set, - (hyphen) comes before the
> numbers.
> One way you can get around this behavior is to replace the hyphens with
> underscore(_) character and do comparison.
>
> If you change the hyphens to underscore, then you will need to revert
> the changes once you are done - this you may not like so much.
>
> To overcome this you can implement a class that implements the
> IComparator interface and pass it along to the sort mechanism - the
> IComparator instance can read the strings replace hyphen to underscore
> and then compare. This will not require a change of your original data
> and hence may be a cleaner solution - except for the fact that you need
> to create another class.
>
- Next message: Subba Rao via DotNetMonster.com: "Re: Help needed with DataGrid Client-Side Scripting"
- Previous message: Banda RamaNarsiReddy via .NET 247: "binding Treeview in datagrid(ASP.Net(C#))"
- In reply to: Samuel Kim: "Re: Sorting Datagrid With Hyphen / Dash"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|