Sorting a varchar field

Stimulsoft Reports.NET discussion
Post Reply
MikeC
Posts: 51
Joined: Mon Jun 07, 2010 3:36 pm

Sorting a varchar field

Post by MikeC »

I have a field that needs to be sorted. It's a varchar field that looks like the following:

1
2
3
3A
4
4A
4B
5
6
6A
6B
6C
11
12
20

Since it's varchar when I just sort it normally I end up with:

1
11
12
2
20
etc....

What's the method to correctly sort varchar fields?
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Sorting a varchar field

Post by Andrew »

Hello,

Sorry we cannot understand your question. Could you, please rephrase it or explain your task in detail?

Thank you.
albloshi
Posts: 14
Joined: Wed Sep 01, 2010 5:39 am
Location: K.S.A

Sorting a varchar field

Post by albloshi »

I also face the same problem

The scenario is that

I have a string column in a dataset

its has the following data

1
2
3
4
4A
10
12
20
22

When this column is placed on the report in the band and this column is sorted

it give
1
10
12
2
20
22
3
4
4A


I also require answer for that
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Sorting a varchar field

Post by Alex K. »

Hello,

The question is not quite clear. If you want to get the data in the order they are in your DataSource, please do not sorting by this field. Since this field is of the string type, then it sorts them as string.

Thank you.
xss
Posts: 64
Joined: Wed Jun 10, 2009 3:03 am
Location: Austria

Sorting a varchar field

Post by xss »

Hi,

since the field type is string, it sorts as string. Pad the string with leading zeros.

Cheers.
mrapi
Posts: 282
Joined: Sat Dec 20, 2008 1:08 am

Sorting a varchar field

Post by mrapi »

Just in idea : follow xss and create a second field just for sorting and display your original field
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Sorting a varchar field

Post by Jan »

Hello,

You can use expression for sorting dataset not only reference to datacolumn. If expression convert your value to numeric. For example:

{decimal.Parse(MyDataSource.MyDataColumn)}

Thank you.
Post Reply