Difficult question, as it depends on so many factors. But, I'll use the extremes in quality as my main guide. That being said, from highest to lowest:
1- Encoding quality. A badly encoded file (think below 96kps) will kill SQ worse than anything else I can think of. Everyone has their own standards, so it's a question of finding that "sweet spot" that works for you.
2- Cans. The difference between $10 ear-buds and even mid-range cans are like night and day.
3- DAP. Not all DAPs sound alike, as many of us know. But I don't think the differences between them are as high as differences between headphones.
4- Amp. Amps are normally supplement and, even though they help with SQ, I think it belongs at the bottom of the list.