changed sorting methods
added documentation