Another attempt to use index when sorting