title: Does A Default Sort Order in DAL Violate Separation of Concerns
body: <p>I have an n-tier application which among other things includes a Data Access Layer (DAL) AND a Business Logic Layer (BLL). I use SQL queries and stored procs in the DAL which I use to fill my objects.</p>
  
  <p>So here's my question:</p>
  
  <p>Does an <code>ORDER BY</code> clause in my SQL queries violate separation of concerns?</p>
  
  <p>On the one hand, it seems that sorting logic belongs in the business layer because it is our business rules that determine why we want to display the data in a particular order.  Also, we may want to display the same data in more than one way. Further, shouldn't my data access code be unaware of concerns such as how it is displayed?</p>
  
  <p>On the other hand databases are generally more efficient at sorting data than application code, so for performance reasons there is an incentive go with an ORDER BY clause over sorting in the BLL. In addition, I'm not sure if specifying a default sort order in the DAL really violates separation of concerns. The records have to come out of the database in some manner. Why not sort them according to the most common scenario? In cases where we need a different sort order than the default, then we can sort via some method in the BLL.</p>