import { ParticipantModel } from '../../store'

export const sortParticipantsBySpeakers = (activeSpeakers: string[], participants: ParticipantModel[]) => {
  const reversedSpeakers = [...activeSpeakers].reverse()
  return participants
    .filter((p) => !!p.id)
    .sort((p1, p2) => reversedSpeakers.indexOf(p2.id!) - reversedSpeakers.indexOf(p1.id!))
}
