# Finding the position on an item in a collection

**URL:** <https://discuss.rubyonrails.org/t/finding-the-position-on-an-item-in-a-collection/17740>\
**Category:** rubyonrails-talk\
**Created:** [September 4, 2007, 1:00pm UTC](https://discuss.rubyonrails.org/t/finding-the-position-on-an-item-in-a-collection/17740 "2007-09-04T13:00:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivor\_Paul](https://avatars.discourse-cdn.com/v4/letter/i/ecae2f/32.png) [@Ivor\_Paul](https://discuss.rubyonrails.org/u/Ivor_Paul)\
**Post date:** [September 4, 2007, 1:00pm UTC](https://discuss.rubyonrails.org/t/finding-the-position-on-an-item-in-a-collection/17740/1 "2007-09-04T13:00:20Z")

</div>

> Here is my 2cents worth, but I would love to learn a better way.
> 
> the\_collection = User.find(:all)
> 
> the\_collection.map(&:id).index(23).
> 
> cheers ivor
> 
> > This feels like it should be easy but i can’t work it out: if i have a collection of stories, ordered by (for example) date, then how do i find out the position of the story with id = (eg) 23 in the collection?
> > 
> > ## I guess this is a ruby question rather than a rails-specific question, but maybe there’s a rails way…
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

>
