About three months after I was hired at a company they reduced headcount by 25%. Even though I was one of the newest people there (though in terms of experience and salary I was more senior), management came to me and said that my experience and flexibility was going to be key in where they were headed post layoff and I wasn't going to be affected.
Long story short, it really depends. It's not always down to salary. Without getting into a lot of legalese (and every situation varies), when you do a layoff, you're eliminating the position and not looking to rehire, so you're generally not thinking about replacements. You're trying to figure out which staff is going to get you from here to wherever you decided you need to be.
There are entire companies dedicated to executing (pardon the pun) layoffs "correctly" and there are as many ways to do it as there are managers, but they essentially fall into three categories: cost-based (get rid of the most cost), skills-based (get rid of the people who don't have skill X that we totally need) and performance-based (get rid of the people who suck). Most of what you're talking about sounds cost-based, in which case there's two philosophies: get rid of the most senior people who charge the most (hello, age discrimination lawsuits) and get rid of a lot of junior people whose productivity is lower and expect the senior people to pick up the slack.
And yes, I have had the privilege of working in a Fortune 500 company and helping put together a layoff list - worst job of my life.