Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SORTING
Message
De
21/10/2001 15:09:49
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
21/10/2001 13:56:19
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00571465
Message ID:
00571472
Vues:
32
>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

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform