>I am having a problem sorting my table correctly. I would like to get all of my contents in field a in alpha order and all of my contents in fieldb in numeric order as the secondary sort.
>
>I have tried this put the field2 does not sort right.
>
>inde on field1 + alltr(str(field2)) to c:\temp\inde1
>
>It doesn't put the field2 in the right order. Field 2 has positives and negative numbers in it. Does anyone know another way to sort this?
Alltr(str()) will left-align your numbers; you need a fixed format, like str(field2,13,2) or so. Keep in mind that the alphabetical order will not work nice with negative numbers. A better way would be to
select * from thetable order by field1, field2 into cursor whatever
and it will respect the numeric order of field2. If you really need an index, there are several other options:
calc min(field2) to nOffset
cOffset=str(nOffset,13,2)
index on field1+str(field2-&cOffset, 13, 2) to c:\temp\inde1 compact
Note the keyword Compact here - "index ... to " will create a foxplus compatible .idx index, which is not compact by default, i.e. uses much more disk space and is not as fast. Alternately you may better index ... tag f1f2 of c:\temp\inde1, which will create a .cdx file.
Yet another alternative, if field2 is integer:
index on field1+bintoc(field2) tag f1f2 of c:\temp\inde1