Added a guard clause to prevent calling sortByIndex with no extra args