Aren't MSDN subscribers suppose to get answers?

G

Guest

I have asked several question over the last week and have not gotten any
answers! What's up with that? Here is one I asked over a week ago:

____________________________________________________________
I am implementing an 'incremental search', where as the user types into a
textbox, a datagridview's current position is updated to match the first
record that contains what the user has typed so far. In this particular
case, I am searching the 'CompanyName' column of the underlying dataview,
which of course is sorted by this column. I have noticed that company names
like "U-Freight" and "U-Haul" appear after company names like "UBS" and "UC
Surgeons" instead of before a company name like "U.S. Steel". But when I am
searching and compare "U-" to "U.S. Steel", it says that the later is the
greater! It appears the '-' is ignored when the sort is done. Is there a
way to change this behavior?
___________________________________________________________________
In a subsequent post, I pointed out that the data was sorted correctly by
SQL server but not by the .NET framework.

I have since discovered that:
1) The data on SQL is varchar, not nvarchar. If it was nvarchar, then it
sorts just like the framework.

2) In oder for this thing to come close to working I needed to change my
search routine to use the following compare:
result = String.Compare(rowval, searchval, True, CC)
where CC = Globalization.CultureInfo.CurrentCulture
but this still leaves some problems with the search.

3)I found the following under help for CompareOption Enumeration:
The .NET Framework uses three distinct ways of sorting: word sort, string
sort, and ordinal sort. Word sort performs a culture-sensitive comparison of
strings. Certain nonalphanumeric characters might have special weights
assigned to them; for example, the hyphen ("-") might have a very small
weight assigned to it so that "coop" and "co-op" appear next to each other in
a sorted list. String sort is similar to word sort, except that there are no
special cases; therefore, all nonalphanumeric symbols come before all
alphanumeric characters. Ordinal sort compares strings based on the Unicode
values of each element of the string.
_________________________________________________________________
Great, so all I have to do is tell the framework I want the 'string sort'
sort! But you can't tell the CompareInfo class what the default sort type
should be! And you can't tell the dataview class to use a different comparer!

This seems to me to be a bug, or at least an oversight.
So if I want it sorted the 'sort string' way, what am I suppose to do? The
only thing I can think of, is to create an arraylist, with the data
(companyname) and an index to the original table, a routine to call the
CompareInfo.compare routine with the compare options I want and then use the
arraylist.sort(mycomparer) an then load the new table based on the sorted
array. Anyone got a better idea? Besides removing the '-' from the data,
which maybe just what I do!
TIA,
 
H

Herfried K. Wagner [MVP]

Terry said:
I have asked several question over the last week and have not gotten any
answers! What's up with that?

You have to register your e-mail address within the MSDN Web site's
subscriber's area in order to enable the MSDN team to identify your question
as being posted by a subscriber. <[email protected]> doesn't seem to be a
valid e-mail address at all.
 
J

Jack Jackson

Welcome to the wonderful world of .NET sorting.

All sorting in .NET apparently uses the culture-sensitve Word sort,
and as far as I can tell it is not changeable.

As you have noticed, this causes a number of problems, such as .NET
applications sorting differently from all other apps. After getting
complaints from several of our users, we went round and round with
Microsoft about this about a couple of years ago, and couldn't find
anyone in Microsoft who thought this was a problem.

The rules of the Word sort bother me. It appears that the Word sort
pretty much ignores all non-alphanumeric characters (actually a
non-alphanumeric character makes the next character sort slightly
before its normal sort position, so that O'Connell sorts before
OConnell). That might not be too bad for a single quote in names (my
AT&T phone book sorts ignoring single quotes), but not for other
characters. My phone book does not ignore dashes - they sort before
"a". I'm not sure how Microsoft decided what the en-US culture sort
should be.

We decided to add another column for names in which we replace (not
remove) the troublesome characters, and sort on that column.
 
M

Michel Posseth [MCP]

If you ask your questions through your subscriber account you wil get the
answers ( there is a nice comunity access link after you log in to MSDN )

regards

Michel
 
G

Guest

I did register this account more then a year ago. And I was getting answers
when I asked and that has changed in the last month or so. I will try
re-registering and see what happens.
 
G

Guest

Thanks Jack,
I have been tearing my hair over this for over a week! You wouldn't think
it would be that hard for Microsoft to expose a PreferedSortMethod property
in the in the CompareInfo class and be done with this! Or even have the
DataView class have an overloaded sort method that allows for a different
comparer like ArrayList does. It seems to me I can get anything sorted the
'sort string' method except a dataview.
Thanks again,
 
G

Guest

I did register this account more then a year ago. And I was getting
answers when I asked and that has changed in the last month or so. I
will try re-registering and see what happens.

Perhaps regular users were replying to your posts?
 
G

Guest

Do I now appear as a subscriber? Interesting that when I went to 'Manage My
Subscriptions', hit the 'Configure' link under Managed NewsGroups, it showed
my posting alias as (e-mail address removed). I tried to change this to Terry
and it was already used. When I went to the 'Profile' link on the newgroup
page, it said my posting alias was (e-mail address removed). I would of thought
that these would always be the same! But I changed it to TerryL and
hopefully you now see me as a subscriber.
 
H

Herfried K. Wagner [MVP]

Terry said:
Do I now appear as a subscriber?

I am not able to check that because I am not from the MSDN support team, but
hopefully they'll now recognize you as a subscriber.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top