added sorting to index