Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / August 2006

Tip: Looking for answers? Try searching our database.

Sorting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adrian - 31 Aug 2006 11:05 GMT
When I sort a number I get a lexicographical sort
1
11
112
1
12
How can I code a sort that will produce
a proper numerical order?

Adrian.
Miha Markic [MVP C#] - 31 Aug 2006 12:00 GMT
Hi Adrian,

Why don't you set column's DataType to a numeric one (I guess you have it
set to string now).

Signature

Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

> When I sort a number I get a lexicographical sort
> 1
[quoted text clipped - 6 lines]
>
> Adrian.
Adrian - 31 Aug 2006 12:13 GMT
> Why don't you set column's DataType to a numeric one (I guess you have it
> set to string now).

Miha,

Yes, but more generally I was looking for an expression like
VALUE([column name]) in a SQL command line.

Adrian.
Miha Markic [MVP C#] - 31 Aug 2006 12:58 GMT
Hi,

So you want to do sorting on database. What database?

Signature

Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

>> Why don't you set column's DataType to a numeric one (I guess you have it
>> set to string now).
[quoted text clipped - 5 lines]
>
> Adrian.
Adrian - 31 Aug 2006 13:10 GMT
> So you want to do sorting on database. What
> database?

SqlServer 2005 Express
Miha Markic [MVP C#] - 31 Aug 2006 13:46 GMT
You might use cast or convert function and sort on the result, something
like ... order by case(comecolumn as int)

Signature

Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

>> So you want to do sorting on database. What
>> database?
>
> SqlServer 2005 Express
Adrian - 31 Aug 2006 16:43 GMT
> You might use cast or convert function and sort on the result, something
> like ... order by case(comecolumn as int)

Great. Thank you.

Adrian
mcw8@aber.ac.uk - 31 Aug 2006 13:40 GMT
> When I sort a number

Youre sorting text, not numbers. It matters little to the computer that
the text is composed entirely of numeric characters - it's text, not a
number

> How can I code a sort that will produce
> a proper numerical order?

Use numbers, not text
Adrian - 31 Aug 2006 16:43 GMT
> Use numbers, not text

Yes, I have changed the code.
Thanks,

Adrian.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.