# Trouble sorting a list of DIVs using scriptaculous

**URL:** <https://www.ruby-forum.com/t/trouble-sorting-a-list-of-divs-using-scriptaculous/121702>\
**Category:** Rails\
**Created:** [November 30, 2007, 2:27am UTC](https://www.ruby-forum.com/t/trouble-sorting-a-list-of-divs-using-scriptaculous/121702 "2007-11-30T02:27:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [November 30, 2007, 2:27am UTC](https://www.ruby-forum.com/t/trouble-sorting-a-list-of-divs-using-scriptaculous/121702/1 "2007-11-30T02:27:11Z")

</div>

I have my view, which displays a simple list of player names, one after  
the other contained in a parent div. They are named item\_1, item\_2,  
item\_3 etc. (based on what position they are in) I have a form that adds  
a new player in a new position, so it adds the player model bla bla,  
thats all fine. The remote form calls a method which calls a .rjs file,  
which updates the div to add the new item at the bottom of the lot. What  
I now need to do and cannot for the life of me figure out is how to then  
sort all the div items (using scriptaculous lets you do that right?) so  
that they are back in 1, 2, 3 order. (for instance, i might have item\_1,  
item\_3 present, and then a player is added with a position of 2, so  
item\_2 is created and put right at the bottom, i need to then sort the  
lot)

Thanks,

Alex
