Fixed sorting and indexing