Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Sort by first part of line

From: greggirwin:mindspring at: 6-Sep-2002 11:36

Hi Scott, Good deal! I used your data generator and then did this: data: read/lines %data-1.txt compare-items: func [a b /local aa bb] [ aa: to integer! first parse a none bb: to integer! first parse b none either aa = bb [0][either aa < bb [-1][1]] ] t: now/time/precise sort/compare data :compare-items print now/time/precise - t halt which gave me these results for 3 runs (on a P900 w/384 Meg of RAM): 1. 0:00:20.099 2. 0:00:20.269 3. 0:00:20.099 Changing the comparisons to use Sunanda's approach (assuming equality is least likely): either aa < bb [-1][either aa > bb [1][0]] 1. 0:00:19.508 2. 0:00:19.528 3. 0:00:19.518 Making the data a hash! didn't speed it up and trying to make it a list! didn't work. Even just a plain SORT on the list didn't work, and inserted 'end for some items. Haven't investigated. The data looks stable at a glance. Not verified though.
>> data
== [" 000 c3wef22aeka 33" " 000 aw333afk c2e 2e" " 000 ake3c2we3 3a2f" " 000 wa2k2c ee3 3fa3" " 000 wa fc32a2k3ee 3" " 000 3k3e32... --Gregg