Hierarchy, of anything, is based on a defined value. In a proper organization, hierarchy is based on competence.
Competence in relation to what? Competence in relation to the work.
Work, defined as decision making and problem solving. Competence begins with the potent combination of capability and skill. A competent person must possess the necessary cognitive capability and the skill to exercise that capability. Skill is a potent combination of technical knowledge and practiced performance. Practiced performance is the expression, the application of competence.
The first question in organizational structure is, who should be the manager? Hierarchy in an organization is based on a value of competence.