 sortBy = (key) ->
     (list) ->
         _.sortBy(list, (k) -> k[key]?.toLowerCase() ? k)
+
 
 exports.Library = rclass ({name}) ->
     displayName : 'Library'

            overflow   : 'auto'

        <div style={style}>
            <h5>
                <strong>{doc.title ? doc.id}</strong>
                {" by #{doc.author}" if doc.author?}
            </h5>

        @scroll_into_view()

    componentWillMount: ->
        meta = @props.library.getIn(['examples'])?.metadata
        docs = @props.library.getIn(['examples'])?.documents

        if docs?
            sortfn = (doc) -> [meta.categories[doc.category], doc.title?.toLowerCase() ? doc.id]
            sdocs  = _.sortBy(docs, sortfn)
            @setState
                copy        : false
                sorted_docs : sdocs
                metadata    : meta

    target_path: ->
        doc = @state.selected
