Page 1 of 1

Logical String Sort

Posted: Fri Jun 27, 2014 3:49 pm
by FS-Adrian
I would like to be able to sort strings logically with the numeric portions of the string sorted the way a user would expect, and like Windows sorts filenames. For example, instead of a straight string sort in this order:

String 1
String 10
String 2
String 3
String 4
String 5
String 6
String 7
String 8
String 9

I would like to be able to to have them sort as:

String 1
String 2
String 3
String 4
String 5
String 6
String 7
String 8
String 9
String 10

Is this possible to sort strings like this in group and data bands?

Thank you very much.

Re: Logical String Sort

Posted: Mon Jun 30, 2014 9:38 am
by HighAley
Hello.

Unfortunately, there is no such sorting.
You could add your own function that will return necessary result.

Thank you.

Re: Logical String Sort

Posted: Mon Jun 30, 2014 1:02 pm
by FS-Adrian
I can easily write a function to perform this comparison, but how can I set the group and data bands to use that sort function instead of the built-in sorting behavior?

Re: Logical String Sort

Posted: Mon Jun 30, 2014 1:34 pm
by HighAley
Hello.

You could create the function that will return value. For example, it could be strings like "01", "02", "10", "03" and etc. or numbers 1, 2, 10, 3 and etc. These data will be sorted by our engine as you need.

Thank you.

Re: Logical String Sort

Posted: Mon Jun 30, 2014 2:31 pm
by FS-Adrian
That won't work for me. The examples I posted are extremely simplistic, the actual data will not have consistent prefixes that I can just strip off to get the numeric value. The actual strings will have numbers and letters with no pre-set pattern. A better example data set would be:

a1
a5
a10
another 5
another 20
another string
b99
b100


Where the non-numeric portion is sorted by a straight string sort, then the following digits are sorted with a numeric sort. I essentially want to replicate the sort behavior that Windows provides for files with mixed numeric and alphabetic characters.

I am retrieving the report data from a database and calling StiReport.RegData to register the data set. If there are no options to accomplish this in Stimulsoft, do you know of a way to handle it on the c# level, possibly with a custom data column type or something like that?

Thank you very much.

Re: Logical String Sort

Posted: Tue Jul 01, 2014 8:36 am
by HighAley
Hello.
FS-Adrian wrote:I am retrieving the report data from a database and calling StiReport.RegData to register the data set. If there are no options to accomplish this in Stimulsoft, do you know of a way to handle it on the c# level, possibly with a custom data column type or something like that?
We have already suggested you to write your own function in report template for sorting in C# and us it in group condition and sort expression.
Unfortunately, we have no such function for you.

Thank you.