I have a function that iterates through a block, tests each value against a given function and is placed in a block associated with the product of that function.CATEGORIZE items testAn example:categorize [    Aardvark Bison    Antelope Baboon    Anaconda Basking Shark] [first item]Results in:[    #A [        Aardvark         Antelope         Anaconda    ]     #B [        Bison         Baboon         Basking Shark    ]]For its test argument, a function! or a block! is accepteda block! is transformed into a function with a single argument item.NB. applying new-line before returning the block neatens the resultant blockfor aesthetic purposes only.Review questions I have are:Is there a more efficient way to evaluate each iteration step?Are there any potential optimization possibilities for common comparisons? e.g. by first letter, etc.This is supposed to be a general-purpose functionare there any glaring cases this function fails? Any enhancement suggestions?The CodeRebol [    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]
Rebol Function to Categorize Items in a Block
sorting;rebol