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

Sorting on a string field

Status
Not open for further replies.

fcullari

IS-IT--Management
Oct 28, 2002
30
0
0
US
I need to sort on a string field and have it list the fields that are separated by comma's
I have style numbers in a large string field - 0559, 0592.0560,057888, 0364, 0258

I want it to list in a column:
0258
0364
0559
0560
057888
0592
 
Interesting one, unfortunately Crystal doesn't have built in functions for sorting arrays, so you need to do so manually.

I couldn't find my thread that describes alternatives to bubble sorting, so here's a bubble sort routine:

whilepintingrecords;
stringvar array MyValues := split({table.field},",");
numbervar x;
numbervar y;
stringvar temp;
for x:=1 to ubound(MyValues)-1 do(
for y:=1 to ubound(MyValues)-x do(
if val(MyValues[y]) > val(MyValues[y+1]) then
(temp := MyValues[y];
MyValues[y] := MyValues[y+1];
MyValues[y+1] := temp)));
Join(MyValues,chr(13))

Looks pretty close, can't test right now.

Do a search on bubble sort if I missed something here.

-k
 
Thanks synapevampire,
If you do come across your article with alternatives to bubble sorting, Please send it to me. I appreciate the example you sent me and I will try and use it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top