Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting strings with integers..
Message
From
11/01/2007 19:47:10
 
 
To
11/01/2007 19:16:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6
Miscellaneous
Thread ID:
01184851
Message ID:
01184856
Views:
26
>I have records HMD1, HMD2, HMD3... HMD10.. if I do a set order to this field, foxpro lists the records as HMD1, HMD10, HMD2, HMD3..
>
>How can I arrange correctly?

It is treating the numeric digits not as integer numbers but as characters. You need to have the value as:

HMD001,HMD002,.....HMD010, etc.

You have to provide sufficient space for the digits to increment. You can alternatively build the index as follows (assuming the field name is mykey):
INDEX ON LEFT(mykey,3)+PADL(SUBSTR(mykey,4),4,"0") TAG mykey
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform