| View previous topic :: View next topic |
| Author |
Message |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Dec 14, 2004 12:47 pm Post subject: Sorting lists |
|
|
When running the following code, I would have thought both lists would be in the same order.
| Code: | list create,1
list create,2
%a = 32
repeat
list add,1,%a @tab() @chr(%a)
list add,2,@chr(%a) @tab() %a
%a = @succ(%a)
until @equal(%a,255)
list savefile,1,c:\ascii.txt
list sort,2
list savefile,2,c:\sorted_ascii.txt
|
Am I over looking something obvious? Anyone have any ideas?
Hooligan  _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Dec 14, 2004 1:04 pm Post subject: |
|
|
VDS does not sort in straight ASCII order. It rather tries to use a more linguistically correct sort order
so that ú, u, and U are all placed together between T and V even though they are far apart in the ASCII
char table.
BTW, sorting text strings is a really complicated matter - ask any lexicographer..
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Dec 14, 2004 1:24 pm Post subject: |
|
|
I had no idea...
Oh, well... Nothing @asc() can't cure!
Ask any mathamatician!
Thanks Dread,
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Dec 14, 2004 4:15 pm Post subject: |
|
|
| Hooligan wrote: | Oh, well... Nothing @asc() can't cure!
Ask any mathamatician! |
He-he. True enough. However if you use values from @asc() for sorting, you may run into another little issue.
VDS does not sort numbers in "natural order", so sorted output will be like this:
1
12
18
2
23
and not:
1
2
12
18
23
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Dec 14, 2004 5:23 pm Post subject: |
|
|
That's what I get for drinking and deriving! _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
|