Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can Vfp sort letters before numbers?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00962818
Message ID:
00962830
Views:
8
This message has been marked as a message which has helped to the initial question of the thread.
>I want to sort character data with letters coming before numbers:
>
>AA
>A1
>A2
>BR
>BZ
>B2
>B8
>1A
>11
>12
>2A
>2B
>
>How would I go about this?

You could do something like:
create cursor c_test (keyvalue C(2))

insert into c_test values('AB')
insert into c_test values('1B')
insert into c_test values('AC')
insert into c_test values('AB')
insert into c_test values('2A')
insert into c_test values('AB')
insert into c_test values('1A')
insert into c_test values('AB')

index on Iif(Isdigit(Left(keyvalue, 1)), 'z', 'a') + Keyvalue tag keyvalue

browse last
where 'z' and 'a' are just whatever characters you want with 'z'>'a'

or for a select statement

select c_test.*, Iif(Isdigit(Left(keyvalue, 1)), 'z', 'a') + Keyvalue as keyvalue from c_test order by keyvalue into cursor c_test2
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform