Ensure middleware order is preserved (#31801)
Ensure middleware order is preserved (#31801)

The order in which middleware must be invoked conditions its behaviour. Currently, this is not being taken into consideration for server since we are generating the array of middleware based on an arbitrary order of the middleware existing in the filesystem. This PR ships a change to generate the array of middleware preserving the order defined in the manifest.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`

azukaru/next.js,zeit/next.js,zeit/next.js,JeromeFitz/next.js,azukaru/next.js,azukaru/next.js,azukaru/next.js,JeromeFitz/next.js,JeromeFitz/next.js,zeit/next.js,JeromeFitz/next.js