Fixing sorting by refactoring the angular functions to not rely on index and use a passed object instead.