Refactor sortTracks to sanity