         @scroll_into_view()
 
     componentWillMount: ->
-        #if next.library != @props.library
+        meta = @props.library.getIn(['examples'])?.metadata
         docs = @props.library.getIn(['examples'])?.documents
+
         if docs?
-            sdocs = sortBy('title')(docs)
+            sortfn = (doc) -> [meta.categories[doc.category], doc.title?.toLowerCase() ? doc.id]
+            sdocs  = _.sortBy(docs, sortfn)
             @setState
                 copy        : false
                 sorted_docs : sdocs
-                metadata    : @props.library.getIn(['examples'])?.metadata
+                metadata    : meta
 
     target_path: ->
         doc = @state.selected

sortBy = (key) ->
    (list) ->
        _.sortBy(list, (k) -> k[key]?.toLowerCase() ? k)

exports.Library = rclass ({name}) ->
    displayName : 'Library'

        evt.nativeEvent.stopImmediatePropagation()
        return false

    select_docs: (list) ->

        item_style =
            width        : '100%'
