index: Working sorting

Signed-off-by: Timothy Gu <timothygu99@gmail.com>