You need to use the #weight parameter <a href="http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#weightval">http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#weightval</a><br>

<br><br><div class="gmail_quote">On Wed, Feb 16, 2011 at 10:58 AM, Leonard den Ottolander.nl <span dir="ltr">&lt;<a href="mailto:drupal@den.ottolander.nl">drupal@den.ottolander.nl</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I&#39;m trying to create a form with a list of items that I get from a<br>
database table. The query elements are sorted reversely to compensate<br>
for the fact that element_children($form) that I call later in my theme<br>
function starts from the end of the array.<br>
<br>
After creating the form array I call drupal_render($form). However it<br>
appears drupal_render() rearranges those form items before it calls my<br>
theme function. This results in a randomly ordered table that I create<br>
from the database elements using theme(&#39;table&#39;).<br>
<br>
Working with Drupal 6.2. Since this is a development site all caching is<br>
currently disabled and I explicitly cleared cached data via<br>
admin/settings/performance as well after I removed table drag items that<br>
I temporarily added. I even disabled, uninstalled, then reinstalled the<br>
module and refilled the table the module uses.<br>
<br>
Is there a way to avoid the reordering of (certain) form elements when<br>
calling drupal_render()? Or am I forced to do the ordering in my theme<br>
function?<br>
<br>
Regards,<br>
Leonard.<br>
<font color="#888888"><br>
--<br>
mount -t life -o ro /dev/dna /genetic/research<br>
<br>
<br>
</font></blockquote></div><br>