# How to sort div elements in Ruby? (Web Automation, Cucumber, Watir)

**URL:** <https://www.ruby-forum.com/t/how-to-sort-div-elements-in-ruby-web-automation-cucumber-watir/253428>\
**Category:** RSpec\
**Tags:** cucumber\
**Created:** [December 6, 2019, 7:08pm UTC](https://www.ruby-forum.com/t/how-to-sort-div-elements-in-ruby-web-automation-cucumber-watir/253428 "2019-12-06T19:08:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruby\_Newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@Ruby\_Newbie](https://www.ruby-forum.com/u/Ruby_Newbie)\
**Post date:** [December 6, 2019, 7:08pm UTC](https://www.ruby-forum.com/t/how-to-sort-div-elements-in-ruby-web-automation-cucumber-watir/253428/1 "2019-12-06T19:08:22Z")

</div>

I have the following problem - I don’t know how I can sort div elements, which have the same class, same id’s, same name, etc. The only thing that differentiates them are the tags inside them.

I am currently learning web automation and I use a Ruby-Cucumber-Watir automation framework.

Here are the div-elements I have (For simplicity’s sake only 2 elements)

```
  <div class=“box mid grey“>
    <a href = „#38“>
  </div>

  <div class=“box mid grey“>
    <a href = „#42“>
  </div>

```

Any help would be greatly appreciated! 🙂
