[ticket/991] Add sorting of categories

http://www.flying-bits.org/tracker.php?p=33&t=991