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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Alphanumberic Field

Status
Not open for further replies.

crystalreport85

Programmer
Sep 27, 2010
51
CA


I got this field
Before sort:
1
44
56
54
54a
56b
54B
3
60
-------------------
I need to sort like the following

1
3
44
54
54a
54B
56b
54
60

Crystal sorts the number first and alpha last.

How do I sort like above?
Any help is appreciated.
Thank you in advance
 
Please review your post, as your second sample makes no sense.

-LB
 
I'm assuming you want to sort the number as a number, followed by the alpha bit when it exists, and the extra "54" is an error.

On that basis, you need to split your fields and then recombine them. For the examples you give, you could try something like
Code:
If Length({your.field}) = 1
then "0" & {your.field}
else {your.field}

If the data is more complex, you might need to use the Right command to get the last character and test it for being numeric or not numeric, etc.

It always helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 

Sorry ..the sort I need is

1
3
44
54
54a
54B
56
56B
60

so on..

I tried this logic
@FSort

end:=right(sNo,1);

if not isnumeric(end) then
sWinNo:=trim(replace(sNo,end,""));
else

sWinNo;

and used Fsort field to sort
and printed {table.sno } field

but the field printed number first and alphanumberic next.
Help me.
Thanks
 
but the field printed number first and alphanumberic next
But that is exactly what you are saying is your desired sort...

Try this:

Make a formula {@val}:

val({table.sno})

Add this as your first sort field. Then add {table.sno} as your second sort field.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top