473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Aren't MSDN subscribers suppose to get answers?

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,
--
Terry
Jul 21 '07 #1
6 1231
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.

On Sat, 21 Jul 2007 13:26:03 -0700, Terry <Te***@nospam.nospamwrote:
>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,
Jul 21 '07 #2

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

"Terry" <Te***@nospam.nospamschreef in bericht
news:DA**********************************@microsof t.com...
>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,
--
Terry

Jul 21 '07 #3
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.
--
Terry
"Michel Posseth [MCP]" wrote:
>
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

"Terry" <Te***@nospam.nospamschreef in bericht
news:DA**********************************@microsof t.com...
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,
--
Terry


Jul 21 '07 #4
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,
--
Terry
"Jack Jackson" wrote:
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.

On Sat, 21 Jul 2007 13:26:03 -0700, Terry <Te***@nospam.nospamwrote:
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,
Jul 21 '07 #5
=?Utf-8?B?VGVycnk=?= <Te***@nospam.nospamwrote in
news:64**********************************@microsof t.com:
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?
Jul 22 '07 #6
"Terry" <Te****@nospam.nospamschrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jul 22 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Brad Ford | last post by:
I see posts concerning the use of Whidbey, I am new to MSDN, and I would very much like to try it out. There is even a "hands on tutorial", but the requirement is that you have Whidbey installed...
33
by: news.microsoft.com | last post by:
To Microsoft and fellow MSDN Universal subscribers... Regarding new MSDN Universal (I mean Premier) price and level changes: 1) Way too expensive for the small and medium developer Universal...
40
by: news.microsoft.com | last post by:
To Microsoft and fellow MSDN Universal subscribers... Regarding new MSDN Universal (I mean Premier) price and level changes: 1) Way too expensive for the small and medium developer Universal...
9
by: Brad Ford | last post by:
I see posts concerning the use of Whidbey, I am new to MSDN, and I would very much like to try it out. There is even a "hands on tutorial", but the requirement is that you have Whidbey installed...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.