# Sortable lists within categories?

**URL:** <https://www.ruby-forum.com/t/sortable-lists-within-categories/124644>\
**Category:** Rails\
**Created:** [December 31, 2007, 1:48pm UTC](https://www.ruby-forum.com/t/sortable-lists-within-categories/124644 "2007-12-31T13:48:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawgaping](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jawgaping](https://www.ruby-forum.com/u/jawgaping)\
**Post date:** [December 31, 2007, 1:48pm UTC](https://www.ruby-forum.com/t/sortable-lists-within-categories/124644/1 "2007-12-31T13:48:13Z")

</div>

Hello, I would like to have many sortable lists each within it’s own  
category item. I would like the categories to be sortable as well as  
to be able to sort items from within each category into different  
categories.

Is this even possible before I stress myself out big time about it?

I’m not the best programmer in the world. Often I will get started on  
something like this and it never gets finished because it’s just  
impossible – thus further killing my programming ego!

I know that I can sort between lists by using the containment  
operator, but I have not seen any code as to what the actions should  
look like. Furthermore, by having categories also sortable will this  
cause any additional problems?

---

<div class="post-metadata">

**Author:** ![jawgaping](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jawgaping](https://www.ruby-forum.com/u/jawgaping)\
**Post date:** [December 31, 2007, 2:46pm UTC](https://www.ruby-forum.com/t/sortable-lists-within-categories/124644/2 "2007-12-31T14:46:18Z")

</div>

I found this it is exactly what I need, although I still don’t know  
what to do in the actions for multiple sortable lists like this.

[http://www.gregphoto.net/sortable/advanced/](http://www.gregphoto.net/sortable/advanced/)

I’ve done single-list sorting before and my action looks like this.

def order\_elements  
params[:elements].each\_with\_index do |id, position|  
Section.update(id, :position =\> position+1)  
end  
end
