title: Is it easier/faster to evaluate CSS selectors LTR or RTL?
body: <p>Given a CSS selector like</p>
  
  <pre><code>ul &gt; li a
  </code></pre>
  
  <p>Would it be easier/faster to evaluate it from left to right, or right to left? (I realize the answers for "easy" and "faster" might be different.. I want the answer to both). I'm about to embark down one of these paths and I don't want to get half way there and then realize I chose the wrong path :)</p>
  
  <p>LTR: Iterate over all the elements in the document, pick out the ones that are <code>ul</code>, then check all their children for <code>li</code>, and then look at their descendants for <code>a</code>.</p>
  
  <p>RTL: Iterate over all the elements in the document, find all the <code>a</code>, filter out the ones that don't have an ancestor that is an <code>li</code>, if it does have an <code>li</code> ancestor, check if its parent is a <code>ul</code>, if not, drop that <code>a</code>.</p>
  
  <p>Also, there isn't really any other way to do this than iterating over <em>all</em> the elements is there?</p>
  
  <hr>
  
  <p>I'm thinking in the context of <em>finding</em> elements, as jQuery does, not in the context of applying styles.</p>