Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort - How do I sort Alpha characters then numbers 3

Status
Not open for further replies.

koonie

Programmer
Jul 26, 2007
4
US
I have a report column that I need to sort in ascending order, first by alpha then numbers. I would like to create a formula to do the sort in Crystal Reports 9 for Visual Studio 2003 or 2005.

Data that I would like to sort:

13-2912004
06-2912004
2331-2912004
931-2912004
ANUSM636AV8
ZZ-0.016KGSQCM
BM400-2
TE6FUA

I need to sort in this order:

ANUSM636AV8
BM400-2
TE6FUA
ZZ-0.016KGSQCM
06-2912004
13-2912004
2331-2912004
931-2912004

Note that this field is variable in length, from 1 to 15 characters.

Any ideas?
Thanks in advance for any suggestions.

--Koonie
 
I think you could create a formula:

if isnumeric(left({table.string},1)) then 2 else 1

Use this formula as your first sort field and then add {table.string} as your second sort field.

-LB
 
Thanks for the suggestion.
The sort pattern works great for the first character.
Any idea how I can apply the logic to continue to sort the entire 15 characters?

Before sort:

A01AD
AA10D
CC01T34
001AGB
0A1TGC

Preferred sort pattern:

AA10D
A01AD
CC01T34
0A1TGC
001AGB

Thanks again.
 
Try this:

stringvar y := {table.string};
numbervar i;
numbervar j := len(y);
stringvar z := "";

for i := 1 to j do(
if isnumeric(y) then
z := z + "9"+y else
z := z + "1"+y
);
z

Use this as your sort field, but display {table.string} on your report.

-LB
 
Hi LB.


Those 2 formulas deserve another star..That need has been driving me nuts..( not a long drive, these days..)




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 

Wow, thanks for the second formula. It works like a charm.
Your help is much appreciated.

--Jim K.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top