[REBOL] Re: Sort by first part of line
From: anton:lexicon at: 6-Sep-2002 16:07
*Right* then, try this:
; data must start with newline to help the parse rule
string: {
454 en tw
395 en th
313 kai o
175 oi de asdf
314 eij thn
174 eij ton
124 kai ouk dffd fder
123 kai thn
219 ek tou
160 kai en tty ttq qzfcv
}
blk: make block! 1000 ; or 2 * number of lines in the string
; that's instead of [copy []], a speed increase for insert
whitespace: charset " ^-" ; spaces and tabs
parse/all string [
some [
"^/" ; each line starts with a newline
some whitespace
copy number to " "
(insert tail blk to integer! number)
" "
copy string to "^/" ; the rest of the line
(insert tail blk string)
]
]
sort/skip blk 2
foreach [one two] blk [print [one two]]
Anton.