Typically when a fleet is retired, there is a displacement bid. What fleet type and seat that you end up in is determined by your relative seniority to everybody else.
The displacement bid may or may not contain negotiated clauses which prevent/contain downgrades or displacement of other pilots.