Re: Sorting Datagrid With Hyphen / Dash

From: Samuel Kim (look341_at_gmail.com)
Date: 03/08/05


Date: 8 Mar 2005 15:45:17 -0800

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.



Relevant Pages

  • Re: Sorting Datagrid With Hyphen / Dash
    ... 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 ... > underscore(_) character and do comparison. ... > If you change the hyphens to underscore, then you will need to revert ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: Is there a way to use filtering in E4X with hyphenated XML elements?
    ... However, if the element contains a hyphen instead of an underscore, ... i.e. company-name, that syntax won't work. ... filtering with elements containing hyphens. ...
    (comp.lang.javascript)
  • Re: Calling a sub
    ... but the sub is called Add-This (hyphen vs ... Hyphens cannot be used in function & variable names. ...
    (microsoft.public.vb.general.discussion)