converted index based sorting to key based sorting