I have an api with 3 layers
1.) The endpoint layer which exposes api endpoint handler functions. These generally call the business layer, aggregate the results to form an http response.
2.) The business logic layer, which provides interfaces to get or edit data while employing business rules behind the scenes, modifying data and enforcing rules. Prevents bloating the api endpoint functions and provides re-usable logic.
3.) the data layer, does the actual modification or querying of the persistence layer (db or otherwise) without applying any logic to the data.
In some of my functions the business layer needs to work with a list of objects retrieved from the data layer which has been sorted by a specific field. There is no case (currently foreseeable) in which the business layer will ever process this list not sorted by that field, so in this case does it make sense to sort the data in the data layer, or does it make more sense to stay pure in layer intentions and even if it means re-sorting the list every time, keep the sorting in the business layer?