  Finite element codes typically use data structures that represent
unstructured meshes as collections of cells, faces, and edges, each of which
require associated coordinate systems. One then needs to store how the
coordinate system of each edge relates to that of neighboring cells. On the
other hand, we can simplify data structures and algorithms if we can a priori
orient coordinate systems in such a way that the coordinate systems on the
edges follows uniquely from those on the cells \textit{by rule}.
  Such rules require that \textit{every} unstructured mesh allows assigning
directions to edges that satisfy the convention in adjacent cells. We show that
the convention chosen for unstructured quadrilateral meshes in the
\texttt{deal.II} library always allows to orient meshes. It can therefore be
used to make codes simpler, faster, and less bug prone. We present an algorithm
that orients meshes in $O(N)$ operations. We then show that consistent
orientations are not always possible for 3d hexahedral meshes. Thus, cells
generally need to store the direction of adjacent edges, but our approach also
allows the characterization of cases where this is not necessary. The 3d
extension of our algorithm either orients edges consistently, or aborts, both
within $O(N)$ steps.
