REBOL [
Title: "Categorize"
Date: 11-Mar-2014
Author: "Christopher Ross-Gill"
Type: 'module
Exports: [categorize]
]
categorize: func [items [block!] test [any-function! block!] /local out value target][
out: copy []
if block? :test [test: func [item] :test]
foreach item items [
value: test item
unless target: select out value [
repend out [value target: copy []]
]
append/only target item
]
foreach [value items] out [new-line/all items true]
new-line/all/skip out true 2
]