fix index sorting