added sorting fixes #3