[REBOL] Re: Sorting non-REBOL data
From: dhsunanda::gmail at: 1-Mar-2010 16:48
What you have, presumably, is a string like this:
str: {122998 720095 100109 00006000 3 ACH
123472 541099 100109 00050216 1 201
123473 541099 100109 00047164 1 201
123534 527401 100109 00000777 1 201
123593 527401 100109 00024206 1 201
123606 548187 100109 00009111 0 COUPON ONLY
123611 548187 100109 00005221 0 COUPON ONLY
123638 551670 100109 00352098 1 101
}
That is not directly sortable as it (in REBOL's eyes) is a single record.
If you can be sure that the only newlines are the record separators,
then you could convert the data into a REBOL block for sorting, and then
convert it back to a string for writing:
blk: parse/all str to-string newline
sort blk ;; default sort will by on leading characters, as per your need
str-2: copy ""
foreach record blk [append str-2 join record newline]
(There may be a better REBOL idiom for those last two lines: creating a
string of records each separated by newline)
Sunanda.