sort/skip
[1/3] from: hijim:pronet at: 12-Nov-2001 10:14
I need to sort a file of homeowner data to print a list for the front
gate codes. There are 7 fields in each record, so I tried:
button blue / 1.2 "Gate List" [
gate-list: copy my-data
sort/skip gate-list 7
print gate-list
]
** Script Error: Invalid argument: 7
** Where: func [face value][
gate-list: copy my-data
sort/skip gate-list 7
print gate-list
]
** Near: sort/skip gate-list 7
print gate-list
Where's the error? Sort works without the skip. Why not with it?
sort/skip -- Treat the series as records of fixed size.
size -- Size of each record. (Type: integer)
Jim
[2/3] from: joel:neely:fedex at: 12-Nov-2001 14:51
Hi, Jim,
Jim Clatfelter wrote:
> I need to sort a file of homeowner data to print a list for the front
> gate codes. There are 7 fields in each record, so I tried:
<<quoted lines omitted: 12>>
> print gate-list
> Where's the error? Sort works without the skip. Why not with it?
What does MY-DATA look like? Is it a block whose length is a
multiple of 7, or is it a block of 7-element blocks? In the
former case, SORT/SKIP...7 should work, but in the latter case
it would cough blood...
>> blk: []
== []
>> repeat i 5 [append blk i loop 6 [append blk random 1000]]
== [1 695 852 380 196 367 232
2 853 912 304 415 171 632
3 767 530 257 786 935 620
4 566 441 445 704 719 260
5 715 897 556 599 936 6...
>> sort/skip/compare blk 7 2
== [4 566 441 445 704 719 260
1 695 852 380 196 367 232
5 715 897 556 599 936 666
3 767 530 257 786 935 620
2 853 912 304 415 171 6...
>> sort/skip blk 7
== [1 695 852 380 196 367 232
2 853 912 304 415 171 632
3 767 530 257 786 935 620
4 566 441 445 704 719 260
5 715 897 556 599 936 6...
in contrast with...
>> blk: []
== []
>> repeat i 5 [
use [bb] [
bb: reduce [i]
loop 6 [append bb random 1000]
append/only blk bb
]
]
== [[1 728 199 380 334 451 455]
[2 733 167 650 919 639 73]
[3 756 674 806 534 37 942]
[4 60 458 444 710 416 518]
[5 839 601 379 559...
>> sort/skip/compare blk 7 2
** Script Error: Invalid argument: 7
** Where: halt-view
** Near: sort/skip/compare blk 7 2
HTH!
-jn-
--
This sentence contradicts itself -- no actually it doesn't.
-- Doug Hofstadter
joel<dot>neely<at>fedex<dot>com
[3/3] from: greggirwin::mindspring::com at: 12-Nov-2001 13:51
Hi Jim,
I'm not sure what the issue might be, but sort/skip works in at least a
simple case.
>> sort/skip [6 5 4 3 2 1] 2
== [2 1 4 3 6 5]
What does the data look like when you pass it to sort?
--Gregg
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted