title: Does BeautifulSoup find_all() preserve tag order?
body: <p>I wish to use BeautifulSoup to parse some HMTL. I have a table with several rows. I'm trying to find a row that meets certain conditions (certain attribute values) and use the index of that row later on in my code.</p>
  
  <p>The question is: does <code>find_all()</code> preserve the order of my rows in the result set that it returns?</p>
  
  <p>I didn't find this in the <a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="noreferrer">docs</a> and Googling got me only to <a href="https://stackoverflow.com/a/27675947">this answer</a>:</p>
  
  <blockquote>
    <p>'BeautifulSoup tags don't track their order in the page, no.'</p>
  </blockquote>
  
  <p>but he does not say where he got that information from.</p>
  
  <p>I'd be happy with an answer, but even more happy with a pointer to some documentation that explains this.</p>
  
  <p>Edit: dstudeba pointed me in the direction of this 'workaround' using <code>next_sibling</code>.</p>
  
  <pre><code>from bs4 import BeautifulSoup
  soup = BeautifulSoup(open('./mytable.html'), 'html.parser')
  row = soup.find('tr', {'class':'something', 'someattr':'somevalue'})
  myvalues = []
  while True:
      cell = row.find('td', {'someattr':'cellspecificvalue'})
      myvalues.append(cell.get_text())
      row = row.find_next_sibling('tr', {'class':'something', 'someattr':'somevalue'})
      if not row:
          break
  </code></pre>
  
  <p>This gets me the cell contents I need in the order they appear in my html file.</p>
  
  <p>However I'd still like to know where in the BeautifulSoup docs I could find whether <code>find_all()</code> preserves order or not. This is why I'm not accepting dstudeba's answer. (my upvote doesn't show, not enough rep yet :P)</p>