|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sorting the Table.DefaultViewFor 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. -- Show quote____________________________________ 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) ----------------------------------------------------------------------------------------------------------------------- "Joe" <jbassking@noemail.noemail> wrote in message news:uTOQy4KFHHA.1356@TK2MSFTNGP06.phx.gbl... >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 > I would add another column (in-memory) to source table which would contain
numbers as numbers and would sort on this column. -- Show quoteMiha Markic [MVP C#, INETA Country Leader for Slovenia] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Joe" <jbassking@noemail.noemail> wrote in message news:uTOQy4KFHHA.1356@TK2MSFTNGP06.phx.gbl... >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 > 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 Show quote "Joe" <jbassking@noemail.noemail> schreef in bericht news:uTOQy4KFHHA.1356@TK2MSFTNGP06.phx.gbl... >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 > |
|||||||||||||||||||||||