It's definitely not random, but it's not perfectly ordered according to merit/performance either.
Some times entire departments are laid off if their projects are part of the cuts. You can be the best performer and still get laid off if you're in the wrong department. Some times companies will identify key employees and ask them to "re-apply" for other positions at the company in other departments.
More often, cuts are made throughout the organization. If the company is laying off 5-10% of employees then it's usually not that difficult to identify underperforming employees if management goes in with a scalpel. However, once the layoffs grow to 20-30% or if the layoffs are imposed at a team level (many teams are 100% good performers) then you have no choice but to lay off good performers as part of the plan.
Actual strategies vary depending on circumstances, but generally you retain people who have the most experience on critical items whereas newer hires and people working on random, nice-to-have type projects are at high risk. Anyone with an unusually high compensation relative to their performance is also a likely target for cuts. If everyone on the team is performing similarly but some people are making 50% more than others (seniority, better negotiating, etc.) then you'd rather lay off two of those employees than three people at more traditional pay. It's about budgets, not headcount.
The other fun trap is that high performers might even be happy with the bottom 5% gone, but it's also easiest for them to find new jobs, so if you cut the bottom 20%, half of the top 10% will also leave.
Some times entire departments are laid off if their projects are part of the cuts. You can be the best performer and still get laid off if you're in the wrong department. Some times companies will identify key employees and ask them to "re-apply" for other positions at the company in other departments.
More often, cuts are made throughout the organization. If the company is laying off 5-10% of employees then it's usually not that difficult to identify underperforming employees if management goes in with a scalpel. However, once the layoffs grow to 20-30% or if the layoffs are imposed at a team level (many teams are 100% good performers) then you have no choice but to lay off good performers as part of the plan.
Actual strategies vary depending on circumstances, but generally you retain people who have the most experience on critical items whereas newer hires and people working on random, nice-to-have type projects are at high risk. Anyone with an unusually high compensation relative to their performance is also a likely target for cuts. If everyone on the team is performing similarly but some people are making 50% more than others (seniority, better negotiating, etc.) then you'd rather lay off two of those employees than three people at more traditional pay. It's about budgets, not headcount.