Add sorting logic to js in timeline
Tidy up
Remove sorting code from backend